/** * The exception that carries an HTTP error out of any layer below a route. * * @module */ import type { APIErrorCode } from "../../shared/api.ts"; /** * An error meant for the client, thrown anywhere below a route; the error * middleware turns it into an `APIFailure` response. */ export class APIException extends Error { /** The error code the response carries. */ readonly code: APIErrorCode; /** The HTTP status the response is sent with. */ readonly status: number; /** Creates an exception answering `status` with `code` and `message`. */ constructor(code: APIErrorCode, status: number, message: string) { super(message); this.code = code; this.status = status; } }