UNPKG

@opra/common

Version:
23 lines (22 loc) 729 B
import { OpraException } from './opra-exception.js'; /** * Defines the base Opra exception, which is handled by the default Exceptions Handler. */ export class OpraHttpError extends OpraException { status; 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); } }