Custom errors thrown in onRequest
do not get proper code
set in onError
#776
Labels
bug
Something isn't working
onRequest
do not get proper code
set in onError
#776
What version of Elysia is running?
1.1.5
What platform is your computer?
Darwin 23.6.0 arm64 arm
What steps can reproduce the bug?
When using custom errors inside an
onRequest()
handler, they don't seem to be handled properly inside theonError
handler. See example below:What is the expected behavior?
If I throw an error inside a route handler,
onError
properly detects it and sets the code to my errors custom name (APIError
). However, if I throw that same error insideonRequest
thecode
comes back asundefined
.I expect it to also be set.
The issue also seems to happen with regular
throw new Error()
errors too. I would expect thecode
for those to be set toUNKNOWN
, but it's still coming back asundefined
.What do you see instead?
The
code
value isundefined
.Furthermore, if this is expected behaviour, then the output seems to be in violation of the types for
code
. Elysia saysundefined
is not one of the possible values. Might need to update the types.Additional information
No response
Have you try removing the
node_modules
andbun.lockb
and try again yet?Yes
The text was updated successfully, but these errors were encountered: