@thalorlabs/errors
Version:
Enhanced exception handling system for TypeScript applications with comprehensive error classes and debugging capabilities
26 lines (25 loc) • 1.17 kB
JavaScript
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.InternalServerError = void 0;
const types_1 = require("@thalorlabs/types");
const CustomError_1 = __importDefault(require("./CustomError"));
/**
* Error for internal server failures and unexpected errors.
*
* Used when unexpected server-side errors occur that cannot be attributed to client input.
* Provides clear 500 error responses with optional error context for debugging.
*
* @example
* throw new InternalServerError('Database connection failed', 'connection-timeout', 'req-123');
*
* throw new InternalServerError('Unexpected error occurred', null, 'req-456', { component: 'payment-processor' });
*/
class InternalServerError extends CustomError_1.default {
constructor(message = 'Internal Server Error', error, requestId, context) {
super(types_1.EHttpServerErrorResponse.INTERNAL_SERVER_ERROR, `${message}${error ? `: ${error}` : ''}`, requestId, context);
}
}
exports.InternalServerError = InternalServerError;
;