Throw real Errors instead of objects
@psavan1655 がすでに取り組んでいます。
2023年4月3日 から。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- typescript
- 領域
- api
調査の方向性
packages/client-account/src/methods/accountCopyIndex.ts と packages/client-account/src/errors/createDestinationIndiceExistsError.ts から始め、その後、issue で参照されている他のエラーヘルパーを調査します。一貫した Error の表現を決定し、throw された失敗が Sentry などのコンシューマーに対して、その名前、メッセージ、実際のスタックトレースを保持していることを検証します。
索引モデルが issue の本文から書いたものです。
説明
This package has a non standard behavior of throwing objects instead of real JS Errors. As it works approximately in the same way in most cases and these objects are similar to Error (at least, TS is ok with that), there are some edge cases where it messes everything up.
My specific use case is with Sentry, which is not able to handle properly these "errors". Instead of having a proper stack trace, I have the Sentry error Non-Error exception captured and all the informations about the real error are lost.
We do this kind of thing all over the package:
throw createDestinationIndiceExistsError()
createDestinationIndiceExistsError.ts
export function createDestinationIndiceExistsError(): Error {
return {
name: 'DestinationIndiceAlreadyExistsError',
message: 'Destination indice already exists.',
};
}
I propose instead to either throw a basic Error with the message...
export function createDestinationIndiceExistsError(): Error {
return new Error('DestinationIndiceAlreadyExistsError');
}
Or even to create custom error objects
class AlgoliaDestinationIndiceAlreadyExistsError extends Error {
constructor(message) {
super(message);
this.name = 'AlgoliaDestinationIndiceAlreadyExistsError';
}
}
export function createDestinationIndiceExistsError(): Error {
return new AlgoliaDestinationIndiceAlreadyExistsError('Destination indice already exists.');
}
I even think that this helper methods are not necessary and that custom errors could be thrown directly. For instance, the custom message is useless in this case.
I can open a PR with a proof of concept if you think it's a good idea. I would also be glad to hear your ideas about the right implementation.
- 主要言語
- TypeScript
- スター
- 1.4k
- フォーク
- 227
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
algolia/algoliasearch-client-javascript のほかの issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
algolia/algoliasearch-client-javascript#1583 · コメント 14 件 · リアクション 9 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 38/100
-
[bug]: Algolia JS Client cause `Bun` to crash on `Hono`再び着手できるかも @PrevailUgah が 238 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンbug
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
algolia/algoliasearch-client-javascript#1601 · コメント 5 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
-
bug
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
algolia/algoliasearch-client-javascript#1594 · コメント 4 件 ·
algolia/algoliasearch-client-javascript の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
volcengine/OpenViking#8432 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
jupyterlab/eslint-plugin#178 · コメント 2 件 ·
-
bug from-app needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
nightly-labs/openbot#16303 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 72/100