Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/http_error/mod.ts>HttpError.json

An error class for HTTP requests.
Latest
method HttpError.json
import { HttpError } from "https://deno.land/x/http_error@0.7.0/mod.ts";

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);

Type Parameters

optional
T extends Record<string, unknown> = Record<string, unknown>

Parameters

error: HttpError<T> | Error | unknown