honojs / honox

HonoX - Hono based meta framework
https://hono.dev
MIT License
1.64k stars 43 forks source link

Global (or cascading) error page #186

Closed venables closed 4 months ago

venables commented 5 months ago

What is the feature you are proposing?

HonoX currently lets you define a _error.tsx error page, but they only work for routes defined at the same level as the file.

For example, an _error.tsx at the root level will not be triggered by errors in a /users/me route. You must define a separate _errors.tsx within the /users directory.

├── app/
│   ├── routes/
│   │   ├── _error.tsx // only works on routes in this folder, not children
│   │   ├── users/
│   │   │   ├── _error.tsx // without this, any /users routes will not have an error page

This leads to having to duplicate an _error.tsx file in every directory of the app.

(You can see the logic in the HonoX code here where it only defined the error handler when the directory matches where the error file was created.

It would be nice to define a single root-level _error.tsx page that will be used for any subdirectories, unless they define one. Or, even better will be to cascade the errors pages, which will use the closest parent _errors.tsx file.

yusukebe commented 5 months ago

Hi @venables

This should be resolved. I'll try to find out a good way. Thanks.