import { HttpError } from "https://deno.land/x/udibo_react_app@0.1.1/app.tsx";
An error for an HTTP request.
Constructors
new
HttpError(status?: number, options?: HttpErrorOptions & T)new
HttpError(message?: string, options?: HttpErrorOptions & T)new
HttpError(options?: HttpErrorOptions & T)new
HttpError(statusOrMessageOrOptions?: number | string | (HttpErrorOptions & T),
messageOrOptions?: string | (HttpErrorOptions & T),
options?: HttpErrorOptions & T,
Properties
data: T
Other data associated with the error.
Determines if the error should be exposed in the response. Defaults to true for client error statuses and false for server error statuses.
Static Methods
from<T extends Record<string, unknown> = Record<string, unknown>>(error: HttpError<T> | Error | unknown): HttpError<T>
Converts any HttpError like objects into an HttpError. If the object is already an instance of HttpError, it will be returned as is.
json<T extends Record<string, unknown> = Record<string, unknown>>(error: HttpError<T> | Error | unknown): HttpErrorOptions & T
Converts an HttpError to an options object that can be used to re-create it. The message will only be included if the error should be exposed.
const error = new HttpError(400, "Invalid id");
const options = HttpError.json(error);
const copy = new HttpError(options);