0

Whenever my code throws an exception the client gets error 500 internal server error.

errors = {
    'UserNotFoundException': {
        'message': 'User does not exist.',
        'status': 404,
    }
}


bp = Blueprint('users', __name__)
api = Api(bp, errors=errors)

I cannot throw UserNotFoundException from my routes without causing error 500. What I've defined in errors seems to be ignored.

ovg
  • 1,486
  • 1
  • 18
  • 30
  • Maybe the answer [here](https://stackoverflow.com/questions/27910503/raising-a-custom-error-with-flask-restful) helps. In general i would also recommend using the flask-restful `abort()` function for this purpose – quantumbyte Feb 21 '18 at 20:44
  • 1
    Possible duplicate of [flask: error\_handler for blueprints](https://stackoverflow.com/questions/12768825/flask-error-handler-for-blueprints) – Farhan Feb 21 '18 at 21:56

0 Answers0