| 49 | }; |
| 50 | // deno-lint-ignore require-await |
| 51 | const DEFAULT_ERROR_HANDLER = async <State>(ctx: Context<State>) => { |
| 52 | const { error } = ctx; |
| 53 | |
| 54 | if (error instanceof HttpError) { |
| 55 | if (error.status >= 500) { |
| 56 | // deno-lint-ignore no-console |
| 57 | console.error(error); |
| 58 | } |
| 59 | const message = error.message || STATUS_TEXT[error.status]; |
| 60 | return new Response(message, { status: error.status }); |
| 61 | } |
| 62 | |
| 63 | // deno-lint-ignore no-console |
| 64 | console.error(error); |
| 65 | return new Response("Internal server error", { status: 500 }); |
| 66 | }; |
| 67 | |
| 68 | export type ListenOptions = |
| 69 | & Partial< |