Next.js Discord

Discord Forum

global-error.tsx file doesn't catch errors

Unanswered
Satin Angora posted this in #help-forum
Open in Discord
Satin AngoraOP
I'm trying to provide i18n to the [error.tsx special file](https://nextjs.org/docs/app/api-reference/file-conventions/error#error) and because it is a client component, I can't load files async. I tried a few things, and noticed that I can create a global-error.tsx file in the root app folder.

However, when I throw an error from a component, I get default Next error page.

For not-found file with similiar issues, I created a slug, [...not-found] inside [lang] slug folder, and threw a notFound error from it to catch errors globally, but I can't find a workaround for error.tsx file.

Any ideas?

2 Replies

Satin AngoraOP
I tried generateStaticParams on error.tsx, but I think it's not supposed to take any other parameter other than default ones.
The project structure is:
src/app
  global-error.tsx
  [lang]/
    custom-error.tsx <- used as a skeleton for global error