skeleton done
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-11-25 23:54:52 +01:00
parent 93ee9ce58c
commit 6e3ba36851
14 changed files with 424 additions and 1 deletions

27
src/errorhandlers.py Normal file
View File

@@ -0,0 +1,27 @@
#!/usr/bin/env python3
"""
Flask error handler functions
"""
__author__ = '@tormakris'
__copyright__ = "Copyright 2020, onSpot Team"
__module_name__ = "errorhandlers"
__version__text__ = "1"
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))