Use correct status code with werkzeug exceptions

Change-Id: Ib726b7d2cc44fbea666d580d7639680bf4bfbcf1
This commit is contained in:
Dmitry Tantsur
2021-08-05 14:52:52 +02:00
parent 00fcd2f4f7
commit 6b11ec4da4
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/')