Updated error object to comply with the API definition
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
ba3d4feab5
commit
7f9a89814c
@ -1,21 +1,20 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
from flask import jsonify
|
||||||
|
|
||||||
|
|
||||||
def get_standard_error_handler(code: int):
|
def get_standard_error_handler(code: int):
|
||||||
|
def error_handler(err):
|
||||||
|
return jsonify({"msg": err.description, "status": str(code)}), code
|
||||||
|
|
||||||
def error_handler(err):
|
return error_handler
|
||||||
return {"msg": str(err)}, code
|
|
||||||
|
|
||||||
return error_handler
|
|
||||||
|
|
||||||
|
|
||||||
def register_all_error_handlers(app):
|
def register_all_error_handlers(app):
|
||||||
"""
|
"""
|
||||||
function to register all handlers
|
function to register all handlers
|
||||||
"""
|
"""
|
||||||
|
|
||||||
error_codes_to_override = [404, 403, 401, 405, 400, 409, 422]
|
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))
|
|
||||||
|
|
||||||
|
for code in error_codes_to_override:
|
||||||
|
app.register_error_handler(code, get_standard_error_handler(code))
|
||||||
|
Loading…
Reference in New Issue
Block a user