From 2c753699ac9c3c4209d5f070855f4315ea468efa Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Sat, 28 Nov 2015 11:18:29 -0500 Subject: [PATCH] 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 --- shade/_utils.py | 8 +++----- shade/exc.py | 5 +++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/shade/_utils.py b/shade/_utils.py index ecab3b34f..3a720efd4 100644 --- a/shade/_utils.py +++ b/shade/_utils.py @@ -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) diff --git a/shade/exc.py b/shade/exc.py index efdccab8c..ed102dd5d 100644 --- a/shade/exc.py +++ b/shade/exc.py @@ -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