reactjs / reactjs/react.dev

handle errors

オープン
#3,336 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

主要言語
JavaScript
スター
11.8k
フォーク
7.9k
平均マージ
1日 11時間
マージ済み PR(30日)
11

説明

The React team believes that server-side errors should be handled in the second then argument. But if an error occurs (an error in our logic) in the first argument of then, it will not be caught. So you think that logic errors should be caught elsewhere (maybe Error Boundary)?
image

fetch('https://jsonplaceholder.typicode.com/todos/1')
  .then(response => response.json())
  .then(json => {
     console.log(json)
     throw new Error('myError') // <= Error here
  },  
    (error) => {
       console.log(error) // <= do not work
    }).catch(error => console.log(error)) // <=  work

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

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

調査の方向性

Issue の fetch 例から始め、then の 2 番目の引数を catch および React Error Boundaries と比較します。最初の callback でスローされたエラーがどのように伝播するかを確認し、次に関連する React ドキュメントのページを特定します。それぞれの種類のエラーがどこで処理されるのかをガイダンスで明確に説明できた時点で、Issue は解決済みとします。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
javascript, react
領域
documentation
issue の種類
ドキュメント
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
20/100

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

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