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
-
area:config bug priority:medium
難度 2/5 1-3 小時 新手友好度 88/100
Doezer/Questarr#1451 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 68/100
sidebandstudio/clawtrate#1156 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100
WenyuChiou/agent-board#1993 ·
維護者通常 1 天內回覆
-
bug design
難度 2/5 1-3 小時 新手友好度 88/100
Colorado-Startups/coloradostartups.org#151 ·
維護者通常 1 天內回覆
-
question
難度 2/5 1-3 小時 新手友好度 78/100
jarrodwatts/claude-hud#883 · 1 則留言 ·
維護者通常 1 天內回覆