@gabliam/web-core
Version:
Gabliam plugin for add web-core
29 lines (28 loc) • 1.05 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.HttpException = void 0;
const tslib_1 = require("tslib");
const statuses_1 = tslib_1.__importDefault(require("statuses"));
const core_1 = require("@gabliam/core");
/**
* Exception web error
*/
class HttpException extends Error {
constructor(response, statusCode, error, otherFields = {}) {
super();
this.response = response;
this.statusCode = statusCode;
this.error = error;
this.otherFields = otherFields;
// Set the prototype explicitly.
Object.setPrototypeOf(this, HttpException.prototype);
this.message = response;
}
getJson() {
return Object.assign(Object.assign({ statusCode: this.statusCode, error: this.error || statuses_1.default.message[this.statusCode] }, (((0, core_1.isObject)(this.response) ? this.response : { message: this.response }))), this.otherFields);
}
getStatus() {
return this.statusCode;
}
}
exports.HttpException = HttpException;