Standardize route error handling to use createExpressError
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 68/100
- issue の種類
- リファクタリング
- 明瞭さ
- おおむね明確
- 活発さ
- 静か
- 技術スタック
- javascript
- 領域
- backend
調査の方向性
rest.js から始めて既存の utils.createExpressError パターンを確認し、次に、next(res) を呼び出す前に res に statusMessage または statusCode を設定している POST ハンドラーをルートファイルから検索します。該当する各エラーパスを標準のエラーオブジェクトパターンに置き換え、これらのハンドラーがすべて作成したエラーを next() に渡すようになったことを確認します。
索引モデルが issue の本文から書いたものです。
説明
Description
The POST handlers in the route files use an unconventional pattern of passing the res object directly to next() as the error argument:
res.statusMessage = 'Improper request method for updating, please use PATCH to add new keys to this object.'
res.status(405)
next(res)
This works because rest.messenger reads err.statusMessage and err.statusCode from whatever object is passed, and the res object happens to have those properties. However, it creates a confusing situation where err === res inside the error handler.
The rest of the codebase uses next(utils.createExpressError({...})) for error handling (see rest.js), which is the standard Express convention.
Standardize these routes to use the same createExpressError pattern as the rest of the codebase:
if (!rest.checkPatchOverrideSupport(req, res)) {
return next(utils.createExpressError({
statusCode: 405,
statusMessage: 'Improper request method for updating, please use PATCH to add new keys to this object.'
}))
}
controller.patchSet(req, res, next)
Context
Found during static review of #206. Out of scope for that PR since it's a pre-existing pattern.
- 主要言語
- JavaScript
- スター
- 3
- フォーク
- 6
- 平均マージ
- 4日 9時間
- マージ済み PR(30日)
- 5
環境構築
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
CenterForDigitalHumanities/rerum_server_nodejs のほかの issue
-
bug documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
-
backend dependencies easy
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
CenterForDigitalHumanities/rerum_server_nodejs#290 · コメント 1 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 50/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 74/100
CenterForDigitalHumanities/rerum_server_nodejs の issue をすべて見る
似ている issue
-
Design only Leadership Survey SLFS
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
bcgov/digital-journeys#2293 ·
-
Toolkit
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
API Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
ProjectSidewalk/SidewalkWebpage#5556 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
jessepollak/home#1454 ·
メンテナーはふだん 1 日以内に返信
-
Mend: dependency security vulnerability untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
opensearch-project/OpenSearch-Dashboards#12822 ·
メンテナーはふだん 1 日以内に返信