Open
Description
I would like to have full control of the response from error handlers assigned using @api.errorhandler
decorator so I can obfuscate the return of calls for some usecases.
For example:
@app.errorhandler(werkzeug.exceptions.BadRequest)
def handle_bad_request(e):
log.error("<error_dump>", error)
response = flask.make_response()
response.set_data(":(")
response.status_code = 418
response.headers['Content-Type'] = 'text/html'
response.headers['Server'] = 'Timex Sinclair'
return response
However, the code assumes full control of the response assuming that a dict is returned.
The change is quite simple. In Api.py after result = handler(e)
:
if not result is None and issubclass(result.__class__, BaseResponse):
return result