express-errorhandlers
Version:
Error handler for expressjs
30 lines • 840 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const DEFAULT_ERROR_MESSAGE = 'Server Error';
const DEFAULT_ERROR_STATUS = 500;
/**
* Error Handler Class
*/
class Handler {
constructor(error, status, message, extra, extraDebug) {
this.error = error || new Error();
this.status = status || DEFAULT_ERROR_STATUS;
this.message = message || DEFAULT_ERROR_MESSAGE;
this.extra = extra || {};
this.extraDebug = extraDebug || {};
}
/**
* Get output data
*/
toData() {
return {
extra: this.extra,
extraDebug: this.extraDebug,
message: this.message,
stack: String(this.error.stack),
status: this.status,
};
}
}
exports.default = Handler;
//# sourceMappingURL=handler.js.map