review fixes
This commit is contained in:
@@ -113,8 +113,8 @@ def wrap_exception(notifier=None, publisher_id=None, event_type=None,
|
||||
# propagated.
|
||||
temp_type = f.__name__
|
||||
|
||||
notifier.safe_notify(publisher_id, temp_type, temp_level,
|
||||
payload)
|
||||
notifier.notify(publisher_id, temp_type, temp_level,
|
||||
payload)
|
||||
|
||||
if not isinstance(e, Error):
|
||||
#exc_type, exc_value, exc_traceback = sys.exc_info()
|
||||
|
||||
@@ -45,14 +45,6 @@ def publisher_id(service, host=None):
|
||||
return "%s.%s" % (service, host)
|
||||
|
||||
|
||||
def safe_notify(publisher_id, event_type, priority, payload):
|
||||
try:
|
||||
notify(publisher_id, event_type, notification_level, payload)
|
||||
except Exception, e:
|
||||
LOG.exception(_("Problem '%(e)s' attempting to "
|
||||
"send to notification system." % locals()))
|
||||
|
||||
|
||||
def notify(publisher_id, event_type, priority, payload):
|
||||
"""
|
||||
Sends a notification using the specified driver
|
||||
@@ -95,4 +87,8 @@ def notify(publisher_id, event_type, priority, payload):
|
||||
priority=priority,
|
||||
payload=payload,
|
||||
timestamp=str(utils.utcnow()))
|
||||
driver.notify(msg)
|
||||
try:
|
||||
driver.notify(msg)
|
||||
except Exception, e:
|
||||
LOG.exception(_("Problem '%(e)s' attempting to "
|
||||
"send to notification system." % locals()))
|
||||
|
||||
@@ -64,11 +64,16 @@ def bad_function_exception():
|
||||
|
||||
|
||||
class WrapExceptionTestCase(test.TestCase):
|
||||
def test_wrap_exception(self):
|
||||
def test_wrap_exception_good_return(self):
|
||||
wrapped = exception.wrap_exception()
|
||||
self.assertEquals(99, wrapped(good_function)())
|
||||
|
||||
def test_wrap_exception_throws_error(self):
|
||||
wrapped = exception.wrap_exception()
|
||||
self.assertRaises(exception.Error, wrapped(bad_function_error))
|
||||
|
||||
def test_wrap_exception_throws_exception(self):
|
||||
wrapped = exception.wrap_exception()
|
||||
# Note that Exception is converted to Error ...
|
||||
self.assertRaises(exception.Error, wrapped(bad_function_exception))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user