"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var __publicField = (obj, key, value) => { __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); return value; }; var GhostError_exports = {}; __export(GhostError_exports, { GhostError: () => GhostError }); module.exports = __toCommonJS(GhostError_exports); var import_uuid = require("uuid"); var import_wrap_stack = require("./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 = (0, import_uuid.v1)(); 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] = (0, import_wrap_stack.wrapStack)(this, options.err); return; } this[property] = options.err[property] || this[property]; }); } } }