summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2013-02-02 16:42:39 +0000
committerGerrit Code Review <review@openstack.org>2013-02-02 16:42:39 +0000
commit864e934cfa7003767dabb4f9a51ebe1e493f6027 (patch)
tree8fb49329d235b3dfb19701a36348f73877c096fc
parentea160989ad2708e59ec77ce855e51d118d5edfb6 (diff)
parentdc99baa33648820b93c90c15bd3562284e8ce4a9 (diff)
downloadoslo-864e934cfa7003767dabb4f9a51ebe1e493f6027.tar.gz
oslo-864e934cfa7003767dabb4f9a51ebe1e493f6027.tar.xz
oslo-864e934cfa7003767dabb4f9a51ebe1e493f6027.zip
Merge "Add _FATAL_EXCEPTION_FORMAT_ERRORS global."
-rw-r--r--openstack/common/exception.py11
-rw-r--r--tests/unit/test_exception.py3
-rw-r--r--tests/utils.py8
3 files changed, 18 insertions, 4 deletions
diff --git a/openstack/common/exception.py b/openstack/common/exception.py
index fa06d6a..4a7c72b 100644
--- a/openstack/common/exception.py
+++ b/openstack/common/exception.py
@@ -23,6 +23,8 @@ import logging
from openstack.common.gettextutils import _
+_FATAL_EXCEPTION_FORMAT_ERRORS = False
+
class Error(Exception):
def __init__(self, message=None):
@@ -121,9 +123,12 @@ class OpenstackException(Exception):
try:
self._error_string = self.message % kwargs
- except Exception:
- # at least get the core message out if something happened
- self._error_string = self.message
+ except Exception as e:
+ if _FATAL_EXCEPTION_FORMAT_ERRORS:
+ raise e
+ else:
+ # at least get the core message out if something happened
+ self._error_string = self.message
def __str__(self):
return self._error_string
diff --git a/tests/unit/test_exception.py b/tests/unit/test_exception.py
index c03a41d..6fe93ac 100644
--- a/tests/unit/test_exception.py
+++ b/tests/unit/test_exception.py
@@ -88,7 +88,8 @@ class OpenstackExceptionTest(utils.BaseTestCase):
err = self.TestException(test=test_message)
self.assertEqual(err._error_string, test_message)
- def test_error_forating_error_string(self):
+ def test_error_formating_error_string(self):
+ self.stubs.Set(exception, '_FATAL_EXCEPTION_FORMAT_ERRORS', False)
err = self.TestException(lol='U mad brah')
self.assertEqual(err._error_string, self.TestException.message)
diff --git a/tests/utils.py b/tests/utils.py
index f9854ca..2d681ae 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -24,6 +24,7 @@ import testtools
from openstack.common import cfg
from openstack.common.fixture import moxstubout
+from openstack.common import exception
CONF = cfg.CONF
@@ -36,6 +37,13 @@ class BaseTestCase(testtools.TestCase):
self.addCleanup(CONF.reset)
self.useFixture(fixtures.FakeLogger('openstack.common'))
self.useFixture(fixtures.Timeout(30, True))
+ self.stubs.Set(exception, '_FATAL_EXCEPTION_FORMAT_ERRORS', True)
+
+ def tearDown(self):
+ super(BaseTestCase, self).tearDown()
+ CONF.reset()
+ self.stubs.UnsetAll()
+ self.stubs.SmartUnsetAll()
def config(self, **kw):
"""