Open lcosmin opened 9 years ago
Output processing does not happen for error handlers. They must return a WSGI conform value (list of byte strings).
This is a limitation of the error handling design and might improve in future versions. The main problem is recursion: What if the output processing of an error handler fails (e.g. json serialisation error)?
I'll keep this issue open as a reminder that this is not solved yet.
Maybe add a @critical_error
that behaves as @error
currently does, and gets called when @error(500)
itself throws an exception?
Output processing does not happen for error handlers. They must return a WSGI conform value (list of byte strings).
That seems to disagree with http://bottlepy.org/docs/dev/tutorial.html#error-pages, which says (emphasis mine):
You can read from request, write to response and return any supported data-type except for HTTPError instances.
In case anyone else needs it, a workaround for the situation @lcosmin presented:
import json
...
@app.error(400)
def eh(error):
data = message(error.body, error.status_code)
return json.dumps(data)
...
noting that this might cause issues if JSON serialization fails.
I've got the following code (using
bottle.py
@854fbd7f88
):I get different results when calling
/bad
and/good
, as it can be seen below:Any idea what's going on?