Export error classes from @hackmd/api
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 74/100
- Issue 类型
- 功能
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- node.js, typescript
- 领域
- api
调研方向
先阅读 nodejs/src/error.ts、包根目录的导出内容和 CommonJS 构建配置,了解公共导出是如何组装的。将错误类添加到两个包入口点,并在 README 中添加一个简短的“处理错误”示例。完成标准是:使用者能够在两种构建中从 @hackmd/api 导入这些类,并且 README 展示如何检查错误类型并访问其详细信息。
由索引模型根据 Issue 内容生成。
描述
Problem
@hackmd/api throws its own error classes, such as HttpResponseError, TooManyRequestsError and InternalServerError (defined in nodejs/src/error.ts), but the package does not export them. Users cannot check the error type:
import { API, TooManyRequestsError } from '@hackmd/api' // not exported
try {
await client.getNote(noteId)
} catch (error) {
if (error instanceof TooManyRequestsError) {
// wait error.resetAfter, then try again
}
}
Today they can only read (error as Error).message, so details such as the HTTP status code or the rate-limit fields userRemaining and resetAfter are hard to reach.
Proposal
Export the error classes from the package root (and the CommonJS build), and add a short "Handle errors" example to the README.
- 主要语言
- TypeScript
- 星标
- 20
- 派生
- 8
- 平均合并
- 47 分钟
- 30 天内合并 PR
- 5
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
hackmdio/api-client 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 45/100
hackmdio/api-client#51 ·
-
难度 5/5 一周以上 新手友好度 45/100
hackmdio/api-client#48 ·
-
难度 5/5 一周以上 新手友好度 20/100
hackmdio/api-client#13 · 1 条评论 · 1 个 reaction ·
-
难度 3/5 1-2 天 新手友好度 35/100
hackmdio/api-client#6 · 1 条评论 ·
-
难度 5/5 一周以上 新手友好度 25/100
hackmdio/api-client#2 · 2 条评论 · 1 个 reaction ·
查看 hackmdio/api-client 的全部 Issue
相似的 Issue
-
Release utils decode git output chunk by chunk, so a multi-byte character can turn into U+FFFD可能已有人在做 @goranai 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
vercel-labs/ui#1494 ·
维护者通常 1 天内回复
-
Task retarget keeps the old host in task scope and adds the new host in a form that matches nothing可能已有人在做 @chaitanya0305 今天认领。 未关闭bug P2
难度 2/5 1-3 小时 新手友好度 62/100
BaaRai/ARTEX#652 · 1 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
compiler-explorer/compiler-explorer#9710 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 72/100
维护者通常 1 天内回复