UNPKG

ts-custom-error

Version:
1 lines 6.16 kB
{"version":3,"file":"custom-error.modern.mjs","sources":["src/utils.js","src/custom-error.js","src/factory.js"],"sourcesContent":["export function fixProto(target, prototype) {\n var setPrototypeOf = Object.setPrototypeOf;\n setPrototypeOf\n ? setPrototypeOf(target, prototype)\n : (target.__proto__ = prototype);\n}\nexport function fixStack(target, fn) {\n if (fn === void 0) { fn = target.constructor; }\n var captureStackTrace = Error.captureStackTrace;\n captureStackTrace && captureStackTrace(target, fn);\n}\n//# sourceMappingURL=utils.js.map","var __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nimport { fixProto, fixStack } from './utils';\nvar CustomError = (function (_super) {\n __extends(CustomError, _super);\n function CustomError(message, options) {\n var _newTarget = this.constructor;\n var _this = _super.call(this, message, options) || this;\n Object.defineProperty(_this, 'name', {\n value: _newTarget.name,\n enumerable: false,\n configurable: true,\n });\n fixProto(_this, _newTarget.prototype);\n fixStack(_this);\n return _this;\n }\n return CustomError;\n}(Error));\nexport { CustomError };\n//# sourceMappingURL=custom-error.js.map","var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\n if (ar || !(i in from)) {\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\n ar[i] = from[i];\n }\n }\n return to.concat(ar || Array.prototype.slice.call(from));\n};\nimport { fixStack } from './utils';\nexport function customErrorFactory(fn, parent) {\n if (parent === void 0) { parent = Error; }\n function CustomError() {\n var args = [];\n for (var _i = 0; _i < arguments.length; _i++) {\n args[_i] = arguments[_i];\n }\n if (!(this instanceof CustomError))\n return new (CustomError.bind.apply(CustomError, __spreadArray([void 0], args, false)))();\n parent.apply(this, args);\n Object.defineProperty(this, 'name', {\n value: fn.name || parent.name,\n enumerable: false,\n configurable: true,\n });\n fn.apply(this, args);\n fixStack(this, CustomError);\n }\n return Object.defineProperties(CustomError, {\n prototype: {\n value: Object.create(parent.prototype, {\n constructor: {\n value: CustomError,\n writable: true,\n configurable: true,\n },\n }),\n },\n });\n}\n//# sourceMappingURL=factory.js.map"],"names":["fixProto","target","prototype","setPrototypeOf","Object","__proto__","fixStack","fn","constructor","captureStackTrace","Error","__extends","message","options","_super","defineProperty","_this","value","_newTarget","name","enumerable","configurable","customErrorFactory","parent","CustomError","args","apply","__spreadArray","defineProperties","create","writable"],"mappings":"AASM,SAAUA,QAAV,CAAmBC,MAAnB,EAAkCC,SAAlC,EAA+C;AACpD,EAAA,IAAMC,cAAc,GAAcC,MAAc,CAACD,cAAjD,CAAA;AACAA,EAAAA,cAAc,GACXA,cAAc,CAACF,MAAD,EAASC,SAAT,CADH,GAETD,MAAc,CAACI,SAAf,GAA2BH,SAFhC,CAAA;AAGA,CAAA;AAQK,SAAUI,QAAV,CAAmBL,MAAnB,EAAkCM,EAAlC,EAAmE;AAAjC,EAAA,IAAA,EAAA,KAAA,KAAA,CAAA,EAAA;IAAAA,EAAeN,GAAAA,MAAM,CAACO,WAAtB,CAAA;AAAiC,GAAA;;AACxE,EAAA,IAAMC,iBAAiB,GAAcC,KAAa,CAACD,iBAAnD,CAAA;AACAA,EAAAA,iBAAiB,IAAIA,iBAAiB,CAACR,MAAD,EAASM,EAAT,CAAtC,CAAA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACCD,IAAA,WAAA,GAAA,UAAA,MAAA,EAAA;AAAiCI,EAAAA,SAAAA,CAAAA,WAAAA,EAAAA,MAAAA,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