Custom Exception handle method not firing


I am trying to get a custom exception to redirect to a route in my application, just to see how it works i created a test exception and placed the routing login in it. here:

'use strict'

const { LogicalException } = require('@adonisjs/generic-exceptions')

class TestException extends LogicalException {
   * Handle this exception by itself
   handle (error,{response}) {

module.exports = TestException

in my route.js file i try to throw the exception and see if it actually redirects. here:

const TestException = use('App/Exceptions/TestException')


Route.get('/test', () => {
  throw new TestException()

As it stands now t, if i run the code by going to that route it breaks the application so i have to pass a message to the exception call which according to the docs is required. Now if i pass that a message into it and run the code by visiting the ‘/test’ route i get the message being displayed there instead of the redirection to the route i set in the handle method.

am i doing something wrong???


@mezie any help with this …


So i guess i was a bit confused at first but after spending some time with the documentation i was able to figure it out. Not only that but also a lot of things. I realized that the docs does not explicitly say everything but it implies a lot of things and you just need to take time and go through to be able to understand.

Back to my problem i realized that the wildcard handler i generated take precedence or higher priority that the custom handlers themselves. So if you define a custom handler and you have a wildcard handler present adonis will use that instead. Thats from my observation tho … i stand to be corrected.