2024-03-08 14:05:00 +01:00
|
|
|
from app.api import bp_errors
|
2024-03-05 16:01:26 +01:00
|
|
|
|
2024-06-02 22:41:14 +02:00
|
|
|
|
2024-03-05 16:01:26 +01:00
|
|
|
@bp_errors.app_errorhandler(400)
|
|
|
|
def bad_request(e):
|
2024-06-02 22:41:14 +02:00
|
|
|
return {
|
|
|
|
"msg": "The request was incorrectly formatted, or contained invalid data"
|
|
|
|
}, 400
|
|
|
|
|
2024-03-05 16:01:26 +01:00
|
|
|
|
|
|
|
@bp_errors.app_errorhandler(401)
|
|
|
|
def unauthorized(e):
|
2024-06-02 22:41:14 +02:00
|
|
|
return {"msg": "Failed to authorize the request"}, 401
|
|
|
|
|
2024-03-05 16:01:26 +01:00
|
|
|
|
|
|
|
@bp_errors.app_errorhandler(403)
|
|
|
|
def forbidden(e):
|
2024-06-02 22:41:14 +02:00
|
|
|
return {"msg": "You shall not pass"}, 403
|
|
|
|
|
2024-03-05 16:01:26 +01:00
|
|
|
|
|
|
|
@bp_errors.app_errorhandler(404)
|
|
|
|
def not_found(e):
|
2024-06-02 22:41:14 +02:00
|
|
|
return {"msg": "The requested resource was not found"}, 404
|
|
|
|
|
2024-03-05 16:01:26 +01:00
|
|
|
|
|
|
|
@bp_errors.app_errorhandler(405)
|
|
|
|
def method_not_allowed(e):
|
2024-06-02 22:41:14 +02:00
|
|
|
return {"msg": "The method used is not allowed in current context"}, 405
|
|
|
|
|
2024-03-05 16:01:26 +01:00
|
|
|
|
|
|
|
@bp_errors.app_errorhandler(500)
|
|
|
|
def internal_error(e):
|
2024-06-02 22:41:14 +02:00
|
|
|
return {"msg": "An error occurred on he server"}, 500
|
|
|
|
|
2024-03-05 16:01:26 +01:00
|
|
|
|
|
|
|
@bp_errors.app_errorhandler(501)
|
2024-06-02 22:41:14 +02:00
|
|
|
def unimplemented_error(e):
|
|
|
|
return {"msg": "This function has not been implemented yet. Check back soon!"}, 501
|