Ok so I followed the instructions in https://adonisjs.com/docs/4.1/exceptions#_handling_exceptions
adonis make:ehandler
now it gave me control to handle the exceptions but what if you want to return the old view that came with adonis

instead of showing this

also is there a way to show the original view for all other exceptions except E_INVALID_SESSION: Invalid session
You can call super.handle
class ExceptionHandler extends BaseExceptionHandler {
async handle (error, ctx) {
return super.handle(...arguments)
}
}
Then return statement is very important
And to manually handle E_INVALID_SESSION, you can simply redirect the user
class ExceptionHandler extends BaseExceptionHandler {
async handle (error, { response }) {
if (error.code === 'E_INVALID_SESSION') {
return response.redirect('back')
}
// handled by parent class
return super.handle(...arguments)
}
}
thanks worked like a charm
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
You can call
super.handleThen
returnstatement is very importantAnd to manually handle
E_INVALID_SESSION, you can simply redirect the user