1 Star 1 Fork 0

masx200 / deno-dns-over-https-server

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
error_handler.tsx 720 Bytes
一键复制 编辑 原始数据 按行查看 历史
// 导入Middleware类型
import {
Context,
Middleware,
NextFunction,
} from "https://cdn.jsdelivr.net/gh/masx200/deno-http-middleware@3.3.0/mod.ts";
// 导入STATUS_TEXT
import { STATUS_TEXT } from "https://deno.land/std@0.189.0/http/http_status.ts";
// 定义error_handler为Middleware类型
export async function error_handler(
_ctx: Context,
next: NextFunction,
): Promise<Response | undefined> {
try {
// 调用next()函数
await next();
} catch (error) {
// 打印错误信息
console.error(error);
// 返回500错误响应
return new Response(`${STATUS_TEXT[500]}` + "\n" + String(error), {
status: 500,
});
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
TypeScript
1
https://gitee.com/masx200/deno-dns-over-https-server.git
git@gitee.com:masx200/deno-dns-over-https-server.git
masx200
deno-dns-over-https-server
deno-dns-over-https-server
main

搜索帮助

344bd9b3 5694891 D2dac590 5694891