twilio/flask-restful — pull request #225 by computmaxer (2014-04-21 06:01:07+00:00)
Title: Ability to define custom error messages

As described in detail in #221, this PR adds the ability for users to define an `errors` dictionary to define a custom response for each exception or error raised during a request.

**Usage:**
```py
errors = {
'UserAlreadyExistsError': {
'message': "A user with that username already exists.",
'status': 409,
},
'ResourceDoesNotExist': {
'message': "A resource with that ID no longer exists.",
'status': 410,
'extra': "Any extra information you want.",
},
}

api = Api(app, errors=errors)
```
Everything in the dict mapped to by the error class name will be added to the response. `'status'` will also set the HTTP status code on the response.