UNPKG

teradatasql

Version:
155 lines 5.66 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); const teradatasql = __importStar(require("teradatasql")); const con = teradatasql.connect({ host: "whomooz", user: "guest", password: "please" }); try { const cur = con.cursor(); try { console.log("Demonstrating how to ignore caught exceptions:"); console.log("drop user NonExistentUser"); try { cur.execute("drop user NonExistentUser"); } catch (ex) { if (ex instanceof teradatasql.OperationalError && ex.message.includes("[Error 3802]")) { console.log("Ignoring", ex.message.split("\n")[0]); } else { throw ex; } } console.log("drop view NonExistentView"); try { cur.execute("drop view NonExistentView"); } catch (ex) { if (ex instanceof teradatasql.OperationalError && ex.message.includes("[Error 3807]")) { console.log("Ignoring", ex.message.split("\n")[0]); } else { throw ex; } } console.log("drop macro NonExistentMacro"); try { cur.execute("drop macro NonExistentMacro"); } catch (ex) { if (ex instanceof teradatasql.OperationalError && ex.message.includes("[Error 3824]")) { console.log("Ignoring", ex.message.split("\n")[0]); } else { throw ex; } } console.log("drop table NonExistentTable"); try { cur.execute("drop table NonExistentTable"); } catch (ex) { if (ex instanceof teradatasql.OperationalError && ex.message.includes("[Error 3807]")) { console.log("Ignoring", ex.message.split("\n")[0]); } else { throw ex; } } console.log("drop database NonExistentDbase"); try { cur.execute("drop database NonExistentDbase"); } catch (ex) { if (ex instanceof teradatasql.OperationalError && ex.message.includes("[Error 3802]")) { console.log("Ignoring", ex.message.split("\n")[0]); } else { throw ex; } } console.log("drop procedure NonExistentProc"); try { cur.execute("drop procedure NonExistentProc"); } catch (ex) { if (ex instanceof teradatasql.OperationalError && ex.message.includes("[Error 5495]")) { console.log("Ignoring", ex.message.split("\n")[0]); } else { throw ex; } } console.log(); console.log("Demonstrating how to ignore a single error:"); console.log("drop table NonExistentTable"); cur.execute("drop table NonExistentTable", undefined, 3807); console.log(); console.log("Demonstrating how to ignore several different errors:"); const nonExistenceErrors = [ 3526, 3802, 3807, 3824, 3913, 4322, 5322, 5495, 5589, 5620, 5623, 5653, 5901, 6808, 6831, 6834, 6849, 6863, 6934, 6938, 7972, 9213, 9403, ]; console.log("drop user NonExistentUser"); cur.execute("drop user NonExistentUser", undefined, nonExistenceErrors); console.log("drop view NonExistentView"); cur.execute("drop view NonExistentView", undefined, nonExistenceErrors); console.log("drop macro NonExistentMacro"); cur.execute("drop macro NonExistentMacro", undefined, nonExistenceErrors); console.log("drop table NonExistentTable"); cur.execute("drop table NonExistentTable", undefined, nonExistenceErrors); console.log("drop database NonExistentDbase"); cur.execute("drop database NonExistentDbase", undefined, nonExistenceErrors); console.log("drop procedure NonExistentProc"); cur.execute("drop procedure NonExistentProc", undefined, nonExistenceErrors); } finally { cur.close(); } } finally { con.close(); } //# sourceMappingURL=IgnoreErrors.js.map