@tunframework/tun
Version:
tun framework for node with typescript
23 lines (22 loc) • 806 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.HttpError = void 0;
const HttpStatus_js_1 = require("./constants/http/HttpStatus.js");
class HttpError extends Error {
status;
constructor({ status, message, error }) {
super();
this.status = status || HttpStatus_js_1.HttpStatus.INTERNAL_SERVER_ERROR;
this.message =
message ||
(error && error.message) ||
(this.status in HttpStatus_js_1.HttpStatusMessage ? HttpStatus_js_1.HttpStatusMessage[this.status] : '');
if (error instanceof Error) {
this.stack = error.stack;
}
else {
Error.captureStackTrace(this, this.constructor);
}
}
}
exports.HttpError = HttpError;