Export error classes from @hackmd/api

オープン 初心者向け
#73 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
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分
マージ済み PR(30日)
5

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

hackmdio/api-client のほかの issue

hackmdio/api-client の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。