UNPKG

@opra/common

Version:
26 lines (25 loc) 885 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.OpraHttpError = void 0; const opra_exception_js_1 = require("./opra-exception.js"); /** * Defines the base Opra exception, which is handled by the default Exceptions Handler. */ class OpraHttpError extends opra_exception_js_1.OpraException { constructor(issue, arg1, arg2) { super(issue, arg1 instanceof Error ? arg1 : undefined); this.status = (typeof arg1 === 'number' ? arg1 : Number(arg2)) || 500; } setStatus(status) { this.status = status; return this; } initError(issue) { if (typeof issue.status === 'number') this.status = issue.status; else if (typeof issue.getStatus === 'function') this.status = issue.getStatus(); super.initError(issue); } } exports.OpraHttpError = OpraHttpError;