"""
+import six
import sys
from oslo.config import cfg
except AttributeError:
pass
+ for k, v in self.kwargs.iteritems():
+ if isinstance(v, Exception):
+ self.kwargs[k] = six.text_type(v)
+
if not message:
try:
message = self.message % kwargs
raise exc_info[0], exc_info[1], exc_info[2]
# at least get the core message out if something happened
message = self.message
+ elif isinstance(message, Exception):
+ message = six.text_type(message)
# NOTE(luisg): We put the actual message in 'msg' so that we can access
# it, because if we try to access the message via 'message' it will be
exc = FakeCinderException(code=404)
self.assertEqual(exc.kwargs['code'], 404)
+
+ def test_error_msg_is_exception_to_string(self):
+ msg = 'test message'
+ exc1 = Exception(msg)
+ exc2 = exception.CinderException(exc1)
+ self.assertEqual(msg, exc2.msg)
+
+ def test_exception_kwargs_to_string(self):
+ msg = 'test message'
+ exc1 = Exception(msg)
+ exc2 = exception.CinderException(kwarg1=exc1)
+ self.assertEqual(msg, exc2.kwargs['kwarg1'])