Confusion about error.tsx vs global-error.tsx #68048
Replies: 2 comments 1 reply
-
|
Hi @g1na1011 From what I read from here and here, you need both: "An error.js boundary will not handle errors thrown in a layout.js component in the same segment because the error boundary is nested inside that layouts component.
"The root app/error.js boundary does not catch errors thrown in the root app/layout.js or app/template.js component. To specifically handle errors in these root components, use a variation of error.js called app/global-error.js located in the root app directory." Which I understand as: global-error.js isn't used when error.js should be but isn't there. |
Beta Was this translation helpful? Give feedback.
-
|
@g1na1011 The issue is you might not be adding and tags in the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi there! We are using Next.js App Router to develop a new architecture for our app. We are starting off with a pure static page that is fairly simple, no nested routes required. Can you help me explain why or when we would want both an
error.tsxand aglobal-error.tsxpage? Our error pages would have the same design, so we thought we can removeerror.tsxand just keepglobal-error.tsx. To our surprise, using justglobal-error.tsxrenders a blank white page when we throw a 500. Renaming that page back toerror.tsxrenders the expected page. Should we have both even though the designs are the same and we do not have a component-based error page?thank you for your help!
Beta Was this translation helpful? Give feedback.
All reactions