twisted/klein — pull request #27 by russellhaering (2013-10-07 17:58:01+00:00)
Title: Allow users to register custom HTTPException handlers

This PR builds on #26 by passing any `HTTPException` raised during routing to the user-defined error handlers. This allows users to do something like:

```python
from werkzeug.exceptions import NotFound

class MyAwesomeThing(object):
app = Klein()

@app.route('/{userid}')
def users_stuff(self, request, userid):
pass

@app.handle_errors(NotFound)
def handle_specific_error(self, request, failure):
request.setResponseCode(404)
return 'Not Found'

@app.handle_errors
def my_error_handler(self, request, failure):
pass
```

Any HTTPException which is not trapped will be returned to the user with the appropriate response code and response body instead of being returned as a generic 500.