Ensure exc message is included in user_message
In exception.handle the user_message was being overridden so failed to include the exception message even if %(exc)s was in the message. This patch ensures the correct user_message is produced by exception.handle() Change-Id: I2bcc041a2f8a3b929c1acbbf3d3ff1e76b5646e9 Closes-Bug: #1493025
This commit is contained in:
parent
299b28ea66
commit
5ca1a52300
@ -334,14 +334,14 @@ def handle(request, message=None, redirect=None, ignore=False,
|
|||||||
|
|
||||||
log_entry = encoding.force_text(exc_value)
|
log_entry = encoding.force_text(exc_value)
|
||||||
|
|
||||||
# We trust messages from our own exceptions
|
|
||||||
user_message = ""
|
user_message = ""
|
||||||
|
# We trust messages from our own exceptions
|
||||||
if issubclass(exc_type, HorizonException):
|
if issubclass(exc_type, HorizonException):
|
||||||
user_message = exc_value
|
user_message = log_entry
|
||||||
# If the message has a placeholder for the exception, fill it in
|
# If the message has a placeholder for the exception, fill it in
|
||||||
elif message and "%(exc)s" in message:
|
elif message and "%(exc)s" in message:
|
||||||
user_message = encoding.force_text(message) % {"exc": log_entry}
|
user_message = encoding.force_text(message) % {"exc": log_entry}
|
||||||
if message:
|
elif message:
|
||||||
user_message = encoding.force_text(message)
|
user_message = encoding.force_text(message)
|
||||||
|
|
||||||
for exc_handler in HANDLE_EXC_METHODS:
|
for exc_handler in HANDLE_EXC_METHODS:
|
||||||
@ -349,7 +349,7 @@ def handle(request, message=None, redirect=None, ignore=False,
|
|||||||
if exc_handler['set_wrap']:
|
if exc_handler['set_wrap']:
|
||||||
wrap = True
|
wrap = True
|
||||||
handler = exc_handler['handler']
|
handler = exc_handler['handler']
|
||||||
ret = handler(request, message, redirect, ignore,
|
ret = handler(request, user_message, redirect, ignore,
|
||||||
exc_handler.get('escalate', escalate),
|
exc_handler.get('escalate', escalate),
|
||||||
handled, force_silence, force_log,
|
handled, force_silence, force_log,
|
||||||
log_method, log_entry, log_level)
|
log_method, log_entry, log_level)
|
||||||
|
Loading…
Reference in New Issue
Block a user