A better approach to hook error handling? #8637
danawoodman
started this conversation in
Ideas
Replies: 1 comment 5 replies
-
Unexpected errors in https://kit.svelte.dev/docs/errors#responses I believe you can also use the https://kit.svelte.dev/docs/modules#sveltejs-kit It's only rendering errors from |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I may be missing something here, but from my current understanding, there is no cannonical way to handle errors within hooks themselves?
For example, I have 4 hooks that are chained together with
sequence
. If any one of these hooks throws an exception the entire application chain breaks down and my users get a 500 error page.On my initial investigation I made the assumption
handleError
would catch this, but on further looking (and Discord chat with Rainlife), it appears that the only approach to handling errors in a hook is to manually return aResponse
?I would suggest/propose a more elegant system of handling these exceptions, so if you have anything non-trivial in a hook (like auth for example), the odds you hit an error are relatively high, and having to wrap everything in
try/catch
es and manually returning rawResponse
objects feels clunky and maybe a better API could be provided?Thinking out loud:
handleError
catch these hook exceptions? That is what I assumed first, and I think its reasonable other people would assume the samesequence
likesequence(hookA, hookB, hookC, errorHandlerHook)
?handleHookError
helper method?I'm sure there are technical reasons that these things may not exist/work this way, but as a consumer, this feels like a rough/unfinished part of the API.
Anyways, just putting my $0.02 out there, apologies if this has been discussed elsewhere but I did some looking and couldnt come up with much.
Beta Was this translation helpful? Give feedback.
All reactions