From 55807333ccb7d80c4e2f074c2a1a10f554e57289 Mon Sep 17 00:00:00 2001 From: "Chris St. Pierre" Date: Fri, 8 Feb 2013 08:12:19 -0500 Subject: Core: deduplicated some error handling code --- src/lib/Bcfg2/Server/Core.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/lib/Bcfg2/Server/Core.py b/src/lib/Bcfg2/Server/Core.py index 81bfebbb5..782aafbf1 100644 --- a/src/lib/Bcfg2/Server/Core.py +++ b/src/lib/Bcfg2/Server/Core.py @@ -552,18 +552,16 @@ class BaseCore(object): continue try: self.Bind(entry, metadata) - except PluginExecutionError: - exc = sys.exc_info()[1] - if 'failure' not in entry.attrib: - entry.set('failure', 'bind error: %s' % exc) - self.logger.error("Failed to bind entry %s:%s: %s" % - (entry.tag, entry.get('name'), exc)) - except Exception: + except: exc = sys.exc_info()[1] if 'failure' not in entry.attrib: entry.set('failure', 'bind error: %s' % exc) - self.logger.error("Unexpected failure in BindStructure: %s %s" - % (entry.tag, entry.get('name')), exc_info=1) + if isinstance(exc, PluginExecutionError): + msg = "Failed to bind entry" + else: + msg = "Unexpected failure binding entry" + self.logger.error("%s %s:%s: %s" % + (msg, entry.tag, entry.get('name'), exc)) def Bind(self, entry, metadata): """ Bind a single entry using the appropriate generator. -- cgit v1.2.3-1-g7c22