var __defProp = Object.defineProperty; var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; var __publicField = (obj, key, value) => { __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); return value; }; import { v1 as uuidv1 } from "uuid"; import { wrapStack } from "./wrap-stack"; class GhostError extends Error { constructor(options = {}) { super(); __publicField(this, "statusCode"); __publicField(this, "errorType"); __publicField(this, "level"); __publicField(this, "id"); __publicField(this, "context"); __publicField(this, "help"); // eslint-disable-next-line @typescript-eslint/no-explicit-any __publicField(this, "errorDetails"); __publicField(this, "code"); __publicField(this, "property"); __publicField(this, "redirect"); __publicField(this, "hideStack"); this.statusCode = 500; this.errorType = "InternalServerError"; this.level = "normal"; this.message = "The server has encountered an error."; this.id = uuidv1(); this.id = options.id || this.id; this.statusCode = options.statusCode || this.statusCode; this.level = options.level || this.level; this.context = options.context; this.help = options.help; this.errorType = this.name = options.errorType || this.errorType; this.errorDetails = options.errorDetails; this.code = options.code || null; this.property = options.property || null; this.redirect = options.redirect || null; this.message = options.message || this.message; this.hideStack = options.hideStack || false; if (options.err) { if (typeof options.err === "string") { options.err = new Error(options.err); } Object.getOwnPropertyNames(options.err).forEach((property) => { if (["errorType", "name", "statusCode", "message", "level"].indexOf(property) !== -1) { return; } if (property === "code") { this[property] = this[property] || options.err[property]; return; } if (property === "stack" && !this.hideStack) { this[property] = wrapStack(this, options.err); return; } this[property] = options.err[property] || this[property]; }); } } } export { GhostError };