tranxpress
Version:
A smart async wrapper for Express with MongoDB transaction support.
25 lines (24 loc) • 758 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ErrorResponse = void 0;
class ErrorResponse extends Error {
constructor(message, statusCode = 500, details) {
super(message);
this.statusCode = statusCode;
this.details = details;
// Maintains proper stack trace (only in V8)
if (Error.captureStackTrace) {
Error.captureStackTrace(this, this.constructor);
}
this.name = this.constructor.name;
}
toJSON() {
return {
status: false,
message: this.message,
statusCode: this.statusCode,
...(this.details && { details: this.details }),
};
}
}
exports.ErrorResponse = ErrorResponse;