Merge "Use correct status code with werkzeug exceptions"

This commit is contained in:
Zuul 2021-08-19 16:21:17 +00:00 committed by Gerrit Code Review
commit 05fcec481e
2 changed files with 6 additions and 1 deletions

View File

@ -0,0 +1,4 @@
---
fixes:
- |
Returns the correct status code (404) when a URL is not found.

View File

@ -167,6 +167,7 @@ def all_exception_handler(message):
url = flask.url_for(flask.request.endpoint, identity=message.args[0])
return flask.redirect(url, code=307, Response=flask.Response)
code = getattr(message, 'code', 500)
if (isinstance(message, error.FishyError)
or isinstance(message, wz_exc.HTTPException)):
app.logger.debug(
@ -175,7 +176,7 @@ def all_exception_handler(message):
app.logger.exception(
'Unexpected %s: %s', message.__class__.__name__, message)
return flask.render_template('error.json', message=message), 500
return flask.render_template('error.json', message=message), code
@app.route('/redfish/v1/')