UNPKG

@expressots/core

Version:

Expressots - modern, fast, lightweight nodejs web framework (@core)

30 lines (29 loc) 1.12 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AppError = void 0; /** * The AppError class extends the built-in Error class in JavaScript, * providing additional properties to manage custom application errors. * It captures detailed information about the error, including a status code * and an optional service identifier, which can be useful for error handling * and logging within the application. * * @extends {Error} */ class AppError extends Error { /** * @param {string} message - The error message to be displayed. * @param {number} [statusCode=500] - The HTTP status code associated with the error (default: 500). * @param {string} [service] - The service identifier associated with the error. */ constructor(message, statusCode, service) { super(message); this.statusCode = statusCode; if (message === null) { this.message = ""; } this.service = service !== undefined ? service : undefined; Error.captureStackTrace(this, this.constructor); } } exports.AppError = AppError;