Don't double-print exception subjects
We're creating an error message string that contains the shade message and the underlying message AND we're passing the underlying message in so that we append it as part of the Inner Exception string. So we wind up with something like: Error in creating volume: Invalid input received: 'size' parameter must be between 75 and 1024 (HTTP 400) (Request-ID: req-ae3f3489-997b-4038-8c9f-efbe7dd73a70) (Inner Exception: Invalid input received: 'size' parameter must be between 75 and 1024) Which is a bit insane. With this change, the above becomes: Error in creating volume (Inner Exception: Invalid input received: 'size' parameter must be between 75 and 1024 (HTTP 400) (Request-ID: req-d4da66b2-41eb-44c8-85f1-064454af5a1c)) And if the shade_exceptions context manager is invoked with no message, the output will be: Invalid input received: 'size' parameter must be between 75 and 1024 (HTTP 400) (Request-ID: req-d4da66b2-41eb-44c8-85f1-064454af5a1c)) Change-Id: I6bd70b70585722d2266ef08496b6860aeeab1824
This commit is contained in:
parent
0d5e7b561e
commit
2c753699ac
@ -444,8 +444,6 @@ def shade_exceptions(error_message=None):
|
||||
except exc.OpenStackCloudException:
|
||||
raise
|
||||
except Exception as e:
|
||||
if error_message is not None:
|
||||
message = "{msg}: {exc}".format(msg=error_message, exc=str(e))
|
||||
else:
|
||||
message = str(e)
|
||||
raise exc.OpenStackCloudException(message)
|
||||
if error_message is None:
|
||||
error_message = str(e)
|
||||
raise exc.OpenStackCloudException(error_message)
|
||||
|
@ -39,10 +39,11 @@ class OpenStackCloudException(Exception):
|
||||
if self.extra_data is not None:
|
||||
message = "%s (Extra: %s)" % (message, self.extra_data)
|
||||
if (self.inner_exception and self.inner_exception[1]
|
||||
and hasattr(self.inner_exception[1], 'message')):
|
||||
and not self.orig_message.endswith(
|
||||
str(self.inner_exception[1]))):
|
||||
message = "%s (Inner Exception: %s)" % (
|
||||
message,
|
||||
self.inner_exception[1].message)
|
||||
str(self.inner_exception[1]))
|
||||
return message
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user