Add handler for bad request error
parent
2b0273cd93
commit
49f9e96b40
|
@ -1,6 +1,6 @@
|
||||||
from flask_restful import Api
|
from flask_restful import Api
|
||||||
from marshmallow import ValidationError
|
from marshmallow import ValidationError
|
||||||
from app.errors import NotPresentError
|
from app.errors import NotPresentError, BadRequestError
|
||||||
from flask import Blueprint, jsonify
|
from flask import Blueprint, jsonify
|
||||||
|
|
||||||
|
|
||||||
|
@ -96,6 +96,12 @@ def handle_not_present_error(e):
|
||||||
return jsonify({'status': 'error', 'message': str(e)}), 404
|
return jsonify({'status': 'error', 'message': str(e)}), 404
|
||||||
|
|
||||||
|
|
||||||
|
@api_bp.errorhandler(BadRequestError)
|
||||||
|
@api_bp.errorhandler(400)
|
||||||
|
def handle_bad_request_error(e):
|
||||||
|
return jsonify({'status': 'error', 'message': str(e)}), 400
|
||||||
|
|
||||||
|
|
||||||
@api_bp.errorhandler(Exception)
|
@api_bp.errorhandler(Exception)
|
||||||
@api_bp.errorhandler(500)
|
@api_bp.errorhandler(500)
|
||||||
def handle_unknown_errors(e):
|
def handle_unknown_errors(e):
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
class NotPresentError(Exception):
|
class NotPresentError(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class BadRequestError(Exception):
|
class BadRequestError(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
Loading…
Reference in New Issue