@belgatitude/http-例外
3⁄4 ̄ ̧漯B ++ 此软件包已移至 https://github.com/belgattitude/httpx (中文(简体) ) ⚠️
没有中断更改, 只是更新从
@belgattitude/http-exception改为@httpx/exception。 。 。 .
愉快的 http 例外 。 以节点、浏览器、 sr 框架和错误记录来计算.
要点
- 很简单: 明确命名的进口 和(或) 状态代码。 。 。 .
- QQ 到处工作:节点,浏览器,边缘... 框架不可知,没有道克.
- 与乐格友好 上下文 信息输入。 少猜游戏.
- 🐎 可序列 以覆盖 Server-Side-Rendering 使用大小写(nextjs, superjson,...).
- 达到标准. 扩展 错误分类 堆栈 财务报告和审定财务报表 错误。 因为 支助.
- 🍃 轻巧 - 说吧 可动摇的树 - 宽 浏览器覆盖 (取舍).
- 默认状态图文集为 错误消息更少的字符,差异...
- (原始内容存档于2018-10-25). QQ IDE Friendly. Typescript - 有mdn和描述链接的tivedoc.
- 🥃 文档 打开 更改日志 - 测试和保养良好 贡献者 欢迎.
文档
👉 见关于 https://belgattitude.github.io/http-unition 页面存档备份,存于互联网档案馆。 。 。
安装
npm install @belgattitude/http-exception # via npm
yarn add @belgattitude/http-exception # via yarn
快开始
简单的命名例外 :
import {
HttpGatewayTimeout,
HttpInternalServerError,
HttpNotFound,
HttpServiceUnavailable,
} from "@belgattitude/http-exception";
throw new HttpNotFound(); // message = 'Not found', statusCode = 404
// Custom message
throw new HttpServiceUnavailable("Service temporarily unavailable");
// Custom context
throw new HttpInternalServerError({
message: "Oups, this is on our side.",
url: "https://api.dev/gateway",
code: "EXTERNAL_SERVICE_TIMEOUT",
cause: new HttpGatewayTimeout({
code: "This Serverless Function has timed out",
errorId: "cdg1::h99k2-1664884491087-b41a2832f559",
}),
});
按状态代码
import { createHttpException } from "@belgattitude/http-exception";
const e404 = createHttpException(404);
const e500 = createHttpException(500, { message: "Server error" });
序列化
import { fromJson, toJson } from "@belgattitude/http-exception/serializer";
const e = new HttpForbidden();
const json = toJson(e);
const deserialized = fromJson(json);
更多文件显示: https://belgattitude.github.io/http-unition 页面存档备份,存于互联网档案馆
支助
不要犹豫和打开 问题。 。 。 .
贡献者
贡献者受到热烈欢迎。 来看看 捐款 文档.
赞助者
如果你喜欢我的一些OSS指南 或为你的公司,我真的很感谢 赞助页:1 咖啡业 或者是掉下来的星星 这给了我一个美味的早晨助推 并帮助我 让我的一些想法成真
许可证
麻省理工学院