Skip to main content


Deno standard library
Go to Latest
import * as mod from "";

A collection of HTTP errors and utilities.

The export errors contains an individual class that extends HttpError which makes handling HTTP errors in a structured way.

The function createHttpError provides a way to create instances of errors in a factory pattern.

The function isHttpError is a type guard that will narrow a value to an HttpError instance.


import { errors, isHttpError } from "";

try {
  throw new errors.NotFound();
} catch (e) {
  if (isHttpError(e)) {
    const response = new Response(e.message, { status: e.status });
  } else {
    throw e;
import { createHttpError } from "";
import { Status } from "";

try {
  throw createHttpError(
    "The request was bad.",
    { expose: false }
} catch (e) {
  // handle errors


The base class that all derivative HTTP extend, providing a status and an expose property.


A map of HttpErrors that are unique instances for each HTTP error status code.


Create an instance of an HttpError based on the status code provided.

A type guard that determines if the value is an HttpError or not.