Improve exception logging with 500 response

Currently when keystone throws a 500 Error, depending on the actual
exception type, it can log the message as an exception or as a warning.

Specifically, if the server throws an exception.UnexpectedError, it
does not log this as an exception; it simply logs it as a warning. This
patch set logs the error as an exception if exception.Error is an
exception.UnexpectedError.

Change-Id: Ia47cc11378ec64d59b7403cb8a284c764148d7a9
Co-Authored-By: Tin Lam <tin@irrational.io>
Closes-Bug: #1717962
This commit is contained in:
Gage Hugo 2017-12-10 12:07:28 -06:00
parent cfbc2aa30b
commit 2be384b60c
1 changed files with 4 additions and 1 deletions

View File

@ -233,7 +233,10 @@ class Application(BaseApplication):
context=req.context_dict,
user_locale=best_match_language(req))
except exception.Error as e:
LOG.warning(six.text_type(e))
if isinstance(e, exception.UnexpectedError):
LOG.exception(six.text_type(e))
else:
LOG.warning(six.text_type(e))
return render_exception(e,
context=req.context_dict,
user_locale=best_match_language(req))