summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2013-06-25 14:56:13 +0000
committerGerrit Code Review <review@openstack.org>2013-06-25 14:56:13 +0000
commitc10bd26135c33cd173b1e52d02ce7865e2b0be17 (patch)
tree06a08c60505561db4f0460137364f58ee67f6382
parent7fe7bd8f39ea4cf10c34cd3daa28d70a8fd76670 (diff)
parent31325752e1d202c95f65b8af0e656b283043f1cd (diff)
downloadoslo-c10bd26135c33cd173b1e52d02ce7865e2b0be17.tar.gz
oslo-c10bd26135c33cd173b1e52d02ce7865e2b0be17.tar.xz
oslo-c10bd26135c33cd173b1e52d02ce7865e2b0be17.zip
Merge "Do not raise NEW exceptions"
-rw-r--r--HACKING.rst10
-rw-r--r--openstack/common/exception.py4
-rw-r--r--tests/unit/rpc/test_common.py2
3 files changed, 13 insertions, 3 deletions
diff --git a/HACKING.rst b/HACKING.rst
index 3cea316..846c1b1 100644
--- a/HACKING.rst
+++ b/HACKING.rst
@@ -46,6 +46,16 @@ General
pass
+- Use 'raise' instead of 'raise e' to preserve original traceback or exception being reraised::
+
+ except Exception as e:
+ ...
+ raise e # BAD
+
+ except Exception:
+ ...
+ raise # OKAY
+
TODO vs FIXME
-------------
diff --git a/openstack/common/exception.py b/openstack/common/exception.py
index cdf40f3..f6c8463 100644
--- a/openstack/common/exception.py
+++ b/openstack/common/exception.py
@@ -122,9 +122,9 @@ class OpenstackException(Exception):
try:
self._error_string = self.message % kwargs
- except Exception as e:
+ except Exception:
if _FATAL_EXCEPTION_FORMAT_ERRORS:
- raise e
+ raise
else:
# at least get the core message out if something happened
self._error_string = self.message
diff --git a/tests/unit/rpc/test_common.py b/tests/unit/rpc/test_common.py
index c2432f4..6f32005 100644
--- a/tests/unit/rpc/test_common.py
+++ b/tests/unit/rpc/test_common.py
@@ -108,7 +108,7 @@ class RpcCommonTestCase(test_utils.BaseTestCase):
'__unicode__': str_override})
new_ex_type.__module__ = '%s_Remote' % e.__class__.__module__
e.__class__ = new_ex_type
- raise e
+ raise
try:
raise_remote_exception()