I have some decorators to handle specific errors from my application like AuthError
or AppError
.
Now I want to handle all other errors that are different from AuthError
or AppError
. Is possible to create a "generic" decorator that get other Exceptions?
For now, my code is:
@api.errorhandler(AuthError)
def handle_auth_error(ex):
logging.warn('An auth error has happened.', ex)
return { 'message': ex.error}, ex.status_code
@api.errorhandler(AppError)
def handle_app_error(ex):
logging.error('An app error has happened.', ex)
return { 'message': ex.error}, ex.status_code