ShotaroHirose59 / nextjs-dashboard

Learn Next.js
https://nextjs-dashboard-dun-pi-28.vercel.app
0 stars 0 forks source link

Chapter13 Handling Errors #22

Open ShotaroHirose59 opened 6 months ago

ShotaroHirose59 commented 6 months ago

In the previous chapter, you learned how to mutate data using Server Actions. Let's see how you can handle errors gracefully using JavaScript's try/catch statements and Next.js APIs. https://nextjs.org/learn/dashboard-app/error-handling

Topic

ShotaroHirose59 commented 6 months ago

error.tsx

error.tsx ファイルを使用して、ルート セグメントの UI 境界を定義できます。 これは、予期しないエラーに対するキャッチオールとして機能し、ユーザーにフォールバック UI を表示できるようにします。

ShotaroHirose59 commented 6 months ago

Handling 404 errors with the notFound function

notFound は存在しないリソースを取得しようとするときに使用できる。 404 エラーを表示して、アクセスしようとしているリソースが見つからなかったことをユーザーに伝えることができる。

notFound()関数でnot-found.tsxをレンダリングできる (サーバーコンポーネントでok)

notFoundはerror.tsxよりも優先される

ShotaroHirose59 commented 6 months ago

Further reading あとでちゃんと見る