Files
sweet/packages/fresh/src/error_test.ts
T
Marvin HagemeisterandBartek Iwańczuk 882b7829fd feat: expose HttpError for clients (#3080)
This PR exposes the `HttpError` class for clients. 

To do that I needed to make the error message optional to avoid bloating
up the bundle with lots of status strings.

Fixes https://github.com/denoland/fresh/issues/2995

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2026-03-26 09:10:21 +01:00

24 lines
650 B
TypeScript

import { expect } from "@std/expect";
import { HttpError } from "./error.ts";
Deno.test("HttpError", () => {
const err = new HttpError(404);
expect(err.status).toEqual(404);
expect(typeof err.stack).toEqual("string");
const err2 = new HttpError(500);
expect(err2.status).toEqual(500);
expect(typeof err2.stack).toEqual("string");
});
Deno.test("HttpError - message", () => {
const err = new HttpError(500, "foo");
expect(err.message).toEqual("foo");
});
Deno.test("HttpError - cause", () => {
const causeErr = new Error();
const err = new HttpError(500, "foo", { cause: causeErr });
expect(err.cause).toEqual(causeErr);
});