Initial commit

This commit is contained in:
2021-12-10 21:59:56 +01:00
commit ccfce10ffa
18 changed files with 444 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
#!/usr/bin/env python3
from flask import jsonify
def get_standard_error_handler(code: int):
def error_handler(err):
return jsonify({"msg": err.description, "status": code}), code
return error_handler
def register_all_error_handlers(app):
"""
function to register all handlers
"""
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))