You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
6.0 KiB

10 months ago
{"version":3,"file":"custom-error.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,