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>
This commit is contained in:
co-authored by
Bartek Iwańczuk
parent
0fff2b04da
commit
882b7829fd
@@ -12,6 +12,7 @@ import { mergePath, type Method, UrlPatternRouter } from "./router.ts";
|
||||
import type { FreshConfig, ResolvedFreshConfig } from "./config.ts";
|
||||
import type { BuildCache } from "./build_cache.ts";
|
||||
import { HttpError } from "./error.ts";
|
||||
import { STATUS_TEXT } from "@std/http/status";
|
||||
import type { LayoutConfig, MaybeLazy, Route, RouteConfig } from "./types.ts";
|
||||
import type { RouteComponent } from "./segments.ts";
|
||||
import {
|
||||
@@ -55,7 +56,8 @@ const DEFAULT_ERROR_HANDLER = async <State>(ctx: Context<State>) => {
|
||||
// deno-lint-ignore no-console
|
||||
console.error(error);
|
||||
}
|
||||
return new Response(error.message, { status: error.status });
|
||||
const message = error.message || STATUS_TEXT[error.status];
|
||||
return new Response(message, { status: error.status });
|
||||
}
|
||||
|
||||
// deno-lint-ignore no-console
|
||||
|
||||
Reference in New Issue
Block a user