"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CustomErrors=exports.CustomError=void 0,exports.makeCustomError=makeCustomError;const config_1=require("../config/config");class CustomError extends Error{constructor(r){super(r.message),this.stack=r.stack,r.code&&(this.code=r.code),r.path&&(this.path=r.path),r.plugin&&(this.plugin=r.plugin),r.hook&&(this.hook=r.hook)}toString(){return`${super.toString()}${this.path?"\nFile: "+this.path:""}`}toJSON(){return{type:"CustomError",message:this.message,stack:this.stack,code:this.code,path:this.path,plugin:this.plugin,hook:this.hook}}}function makeCustomError(r,o,t){if(r instanceof CustomError)return o&&!r.code&&(r.code=o),t&&!r.path&&(r.path=t),r;return new CustomError({code:o||exports.CustomErrors.SUMMER_PLUGIN_ERR,message:r instanceof Error?r.toString():"string"==typeof r?r:"Unknown Error Message "+r,path:t,stack:r instanceof Error?null==r?void 0:r.stack:void 0})}exports.CustomError=CustomError,exports.CustomErrors={SUMMER_PLUGIN_ERR:config_1.SUMMER_PLUGIN_ERR,SUMMER_PLUGIN_CODE_ERR:config_1.SUMMER_PLUGIN_CODE_ERR};