Custom Exception Handling Priority Not Working as Expected #4954
Unanswered
MatheusFerreira71
asked this question in
Help
Replies: 0 comments
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.
-
Hey everyone,
I’m currently creating custom exceptions in my AdonisJS application, but it seems like the framework isn’t handling them as described in the documentation. Every time I throw a custom exception, the global
Handler.ts::handle
method is triggered instead of thehandle()
method inside my custom exception class.According to the documentation:
👉 https://v5-docs.adonisjs.com/guides/exception-handling#custom-exceptions
…you should be able to define a
handle()
method inside your exception, and Adonis will delegate the response rendering to it.While investigating the issue, I found this discussion:
🔗 #718 (comment)
And to make it work properly, I had to apply the workaround mentioned here:
🔧 #718 (comment)
However, based on the documentation, shouldn't the exception automatically self-handle when the
handle()
method is defined inside the custom class?Here’s an example of my custom exception:
Adonis version:
"@adonisjs/core": "^5.8.0"
Would love to hear if this is expected behavior or if I might be missing something here.
Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions