4
0
This repository has been archived on 2020-07-25. You can view files and clone it, but cannot push or open issues or pull requests.
classification-service/classification_service/utils/error_handlers.py
marcsello fd83e268ef
All checks were successful
continuous-integration/drone/push Build is passing
Initial commit
2020-04-15 00:33:06 +02:00

19 lines
422 B
Python

#!/usr/bin/env python3
def get_standard_error_handler(code: int):
def error_handler(err):
return {"msg": str(err)}, code
return error_handler
# function to register all handlers
def register_all_error_handlers(app):
error_codes_to_override = [404, 403, 401, 405, 400, 409, 422]
for code in error_codes_to_override:
app.register_error_handler(code, get_standard_error_handler(code))