!function(global,factory){"object"==typeof exports&&"undefined"!=typeof module?factory(exports):"function"==typeof define&&define.amd?define(["exports"],factory):factory((global=global||self).tsCustomError={})}(this,function(exports){function fixStack(target,fn){void 0===fn&&(fn=target.constructor);var captureStackTrace=Error.captureStackTrace;captureStackTrace&&captureStackTrace(target,fn)}_extendStatics=function(d,b){return(_extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)Object.prototype.hasOwnProperty.call(b,p)&&(d[p]=b[p])})(d,b)};var _extendStatics,__extends=function(d,b){if("function"!=typeof b&&null!==b)throw new TypeError("Class extends value "+String(b)+" is not a constructor or null");function __(){this.constructor=d}_extendStatics(d,b),d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)},CustomError=function(_super){function CustomError(message,options){var setPrototypeOf,_newTarget=this.constructor,message=_super.call(this,message,options)||this;return Object.defineProperty(message,"name",{value:_newTarget.name,enumerable:!1,configurable:!0}),options=message,_newTarget=_newTarget.prototype,(setPrototypeOf=Object.setPrototypeOf)?setPrototypeOf(options,_newTarget):options.__proto__=_newTarget,fixStack(message),message}return __extends(CustomError,_super),CustomError}(Error),__spreadArray=function(to,from,pack){if(pack||2===arguments.length)for(var ar,i=0,l=from.length;i<l;i++)!ar&&i in from||((ar=ar||Array.prototype.slice.call(from,0,i))[i]=from[i]);return to.concat(ar||Array.prototype.slice.call(from))};exports.CustomError=CustomError,exports.customErrorFactory=function(fn,parent){function CustomError(){for(var args=[],_i=0;_i<arguments.length;_i++)args[_i]=arguments[_i];if(!(this instanceof CustomError))return new(CustomError.bind.apply(CustomError,__spreadArray([void 0],args,!1)));parent.apply(this,args),Object.defineProperty(this,"name",{value:fn.name||parent.name,enumerable:!1,configurable:!0}),fn.apply(this,args),fixStack(this,CustomError)}return void 0===parent&&(parent=Error),Object.defineProperties(CustomError,{prototype:{value:Object.create(parent.prototype,{constructor:{value:CustomError,writable:!0,configurable:!0}})}})}});