Open JavaScriptDude opened 2 years ago
The only way to do this is at present is by doing the following which is not ideal at all and it does not allow overriding of Content-Type
.
app = Flask()
app.config['ERROR_INCLUDE_MESSAGE'] = False
# ...
@app.errorhandler(werkzeug.exceptions.BadRequest)
def handle_bad_request(e):
log.error("<error_dump>", error)
return (":(", 418, Headers({'Server': 'Timex Sinclair'}))
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:
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)
: