Return a custom JSON when defining a new bouncer #3884
-
I'm using the @Adonisjs/bouncer and I can't find anything in the documentation to return custom JSON or how I can handle the multi-lang using i18n
But I can't return a custom JSON or handle the multi-lang |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Bouncer raises the Trimmed down version of Exception handler handle(error, ctx) {
if(error.code === 'E_AUTHORIZATION_FAILURE') {
ctx.response.status(error.status).send({ message: error.message })
}
} |
Beta Was this translation helpful? Give feedback.
Bouncer raises the
AuthorizationException
withE_AUTHORIZATION_FAILURE
error code. You can simply capture this exception inside the global exception handler and return whatever you like from there.Trimmed down version of Exception handler