From: Zane Bitter Date: Fri, 2 Aug 2013 13:33:07 +0000 (+0200) Subject: Resource: Clean up exception handling and error messages X-Git-Tag: 2014.1~283^2 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=9f58796ae6abe525ef71fd28e06a95d8e4528c60;p=openstack-build%2Fheat-build.git Resource: Clean up exception handling and error messages Change-Id: Ibd93e8b22bca708ced8ed8c29760fef73a649255 --- diff --git a/heat/engine/resource.py b/heat/engine/resource.py index 143a28d9..f23ce1cf 100644 --- a/heat/engine/resource.py +++ b/heat/engine/resource.py @@ -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: