UNPKG

@halsp/http

Version:

支持 Halsp HTTP 请求

39 lines 1.27 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.HttpException = void 0; const http_status_codes_1 = require("http-status-codes"); const header_handler_1 = require("../context/header-handler.cjs"); const core_1 = require("@halsp/core"); // eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging class HttpException extends core_1.HalspException { status; constructor(status, error) { super(error); this.status = status; if (!this.message) { this.message = (0, http_status_codes_1.getReasonPhrase)(status); } this.name = this.constructor.name; (0, header_handler_1.initHeaderHandler)(this, () => this.headers, () => this.headers); } #headers = {}; get headers() { return this.#headers; } toPlainObject() { const obj = { status: this.status, message: this.message, }; if (this.error && !(0, core_1.isString)(this.error)) { Object.assign(obj, this.error); delete obj["inner"]; return obj; } else { return obj; } } } exports.HttpException = HttpException; //# sourceMappingURL=http-exception.js.map