]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
Resource: Clean up exception handling and error messages
authorZane Bitter <zbitter@redhat.com>
Fri, 2 Aug 2013 13:33:07 +0000 (15:33 +0200)
committerZane Bitter <zbitter@redhat.com>
Fri, 2 Aug 2013 13:33:07 +0000 (15:33 +0200)
Change-Id: Ibd93e8b22bca708ced8ed8c29760fef73a649255

heat/engine/resource.py

index 143a28d90d3a4151e8bbb0f440cfa05f030b8685..f23ce1cfdc75870561fe825b081e9d5e52058af9 100644 (file)
@@ -689,16 +689,15 @@ class Resource(object):
         to implement the signal, the base-class raise an exception if no
         handler is implemented.
         '''
-        if self.action in (self.SUSPEND, self.DELETE):
-            raise exception.ResourceFailure(Exception(
-                'Can not send a signal to a Resource whilst actioning a %s' %
-                self.action))
+        try:
+            if self.action in (self.SUSPEND, self.DELETE):
+                msg = 'Cannot signal resource during %s' % self.action
+                raise Exception(msg)
 
-        if not callable(getattr(self, 'handle_signal', None)):
-            raise exception.ResourceFailure(Exception(
-                'Resource %s is not able to receive a signal' % str(self)))
+            if not callable(getattr(self, 'handle_signal', None)):
+                msg = 'Resource %s is not able to receive a signal' % str(self)
+                raise Exception(msg)
 
-        try:
             self._add_event('signal', self.status, details)
             self.handle_signal(details)
         except Exception as ex: