How to handle global errors? #2815
Unanswered
Barbapapazes
asked this question in
Q&A
Replies: 1 comment
-
Hooks are "interceptors" they should avoid any behavior that stops handling by throwing errors and nitro internals as well tries to make sure they won't fail the whole request. You can either use the classic method of global middleware or prefer explicit composables which i would recommend even though they are more verbose, they make application logic much more clear and predictable. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I'm throwing an error in a
request
hook but if I'm correctly understanding this https://github.com/unjs/nitro/blob/v2/src/runtime/internal/app.ts#L40, the error is not thrown and the request will continue through the application.How to stop the request from a hook? Or should I use a middleware?
A middleware seems to be working.
Beta Was this translation helpful? Give feedback.
All reactions