Simplify common base exception prototype

It seems there's no gain in trying to be smarter and different from the
base Python Exception, so let's remove our custom code to be more
compatible and friendly with all Python versions.

Change-Id: I259783ef1f77c6661ea7dc2325605c8d6290b898
This commit is contained in:
Julien Danjou 2013-12-02 15:02:23 +01:00
parent 86b0750f3e
commit 2b9bafd269
3 changed files with 7 additions and 16 deletions

View File

@ -19,12 +19,6 @@ __all__ = ['MessagingException', 'MessagingTimeout', 'InvalidTarget']
class MessagingException(Exception):
"""Base class for exceptions."""
def __init__(self, msg=None):
self.msg = msg
def __str__(self):
return self.msg
class MessagingTimeout(MessagingException):
"""Raised if message sending times out."""

View File

@ -15,6 +15,7 @@
import sys
import six
import testscenarios
from oslo import messaging
@ -161,7 +162,6 @@ class DeserializeRemoteExceptionTestCase(test_utils.BaseTestCase):
args=['test'],
kwargs={},
str='test\ntraceback\ntraceback\n',
message='test',
remote_name='Exception',
remote_args=('test\ntraceback\ntraceback\n', ),
remote_kwargs={})),
@ -173,7 +173,6 @@ class DeserializeRemoteExceptionTestCase(test_utils.BaseTestCase):
args=[],
kwargs={},
str='test\ntraceback\ntraceback\n',
message='I am Nova',
remote_name='NovaStyleException_Remote',
remote_args=('I am Nova', ),
remote_kwargs={})),
@ -185,7 +184,6 @@ class DeserializeRemoteExceptionTestCase(test_utils.BaseTestCase):
args=['testing'],
kwargs={},
str='test\ntraceback\ntraceback\n',
message='testing',
remote_name='NovaStyleException_Remote',
remote_args=('testing', ),
remote_kwargs={})),
@ -197,7 +195,6 @@ class DeserializeRemoteExceptionTestCase(test_utils.BaseTestCase):
args=[],
kwargs={'who': 'Oslo'},
str='test\ntraceback\ntraceback\n',
message='I am Oslo',
remote_name='KwargsStyleException_Remote',
remote_args=('I am Oslo', ),
remote_kwargs={})),
@ -299,9 +296,9 @@ class DeserializeRemoteExceptionTestCase(test_utils.BaseTestCase):
self.assertIsInstance(ex, self.cls)
self.assertEqual(ex.__class__.__name__, self.remote_name)
self.assertEqual(str(ex), self.str)
self.assertEqual(six.text_type(ex), self.str)
if hasattr(self, 'msg'):
self.assertEqual(ex.msg, self.msg)
self.assertEqual(six.text_type(ex), self.msg)
self.assertEqual(ex.args, (self.msg,) + self.remote_args)
else:
self.assertEqual(ex.message, self.message)
self.assertEqual(ex.args, self.remote_args)
self.assertEqual(ex.args, self.remote_args)

View File

@ -18,6 +18,7 @@ import itertools
import fixtures
import mox
from oslo.config import cfg
import six
from stevedore import driver
import testscenarios
@ -181,8 +182,7 @@ class GetTransportSadPathTestCase(test_utils.BaseTestCase):
self.assertIsInstance(ex, messaging.MessagingException)
self.assertIsInstance(ex, ex_cls)
self.assertTrue(hasattr(ex, 'msg'))
self.assertIn(ex_msg_contains, ex.msg)
self.assertIn(ex_msg_contains, six.text_type(ex))
for k, v in self.ex.items():
self.assertTrue(hasattr(ex, k))