Custom Exceptions problems #1271
-
I created my custom exception: export default class ExpectedException extends Exception {
constructor(message: string) {
super(message, 400, 'E_EXPECTED_EXCEPTION')
}
public async handle(error: this, { response }: HttpContextContract) {
return response
.status(error.status)
.send({ message: error.message })
}
} And then I throw the error from inside the controller method: throw new ExpectedException('Error test') My global handler: export default class ExceptionHandler extends HttpExceptionHandler {
constructor() {
super(Logger)
}
public async handle(error, { response }: HttpContextContract) {
return response
.status(error.status)
.send({ error: 'G HANDLER' })
}
} How do I return the |
Beta Was this translation helpful? Give feedback.
Answered by
popovicieduard
Jul 19, 2020
Replies: 1 comment 2 replies
-
in Instead of
use:
and don't forget to edit the handle method: |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
fnoquiq
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
in
App/Exceptions/Handler.ts
Instead of
use:
and don't forget to edit the handle method:
public async handle(error, ctx: HttpContextContract)