UNPKG

trapx

Version:

A plug-and-play middleware for standardized error handling in TypeScript-based Express.js applications

17 lines (16 loc) 613 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.BaseError = void 0; class BaseError extends Error { constructor(message, statusCode = 500, metadata = {}) { super(message); Object.setPrototypeOf(this, new.target.prototype); this.name = this.constructor.name; this.statusCode = statusCode; this.code = metadata.code || this.name; this.isOperational = metadata.isOperational ?? true; this.details = metadata.details || {}; Error.captureStackTrace(this, this.constructor); } } exports.BaseError = BaseError;