Add handler for bad request error

develop
Ensar Sarajčić 2018-11-03 18:32:35 +01:00
parent 2b0273cd93
commit 49f9e96b40
2 changed files with 8 additions and 1 deletions

View File

@ -1,6 +1,6 @@
from flask_restful import Api
from marshmallow import ValidationError
from app.errors import NotPresentError
from app.errors import NotPresentError, BadRequestError
from flask import Blueprint, jsonify
@ -96,6 +96,12 @@ def handle_not_present_error(e):
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(500)
def handle_unknown_errors(e):

View File

@ -1,5 +1,6 @@
class NotPresentError(Exception):
pass
class BadRequestError(Exception):
pass