From 7803fb8bfa8f0dff547f5a38616643a489e902f0 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Wed, 29 Sep 2010 10:08:00 -0400 Subject: [PATCH] Log errors when instantiation fails in hooke.util.pluggable.construct_*(). --- hooke/util/pluggable.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/hooke/util/pluggable.py b/hooke/util/pluggable.py index 1379c82..a0a669d 100644 --- a/hooke/util/pluggable.py +++ b/hooke/util/pluggable.py @@ -97,7 +97,12 @@ def construct_odict(this_modname, submodnames, class_selector, obj = getattr(submod, objname) if class_selector(obj): if instantiate == True: - obj = obj() + try: + obj = obj() + except Exception, e: + logging.error('could not instantiate %s from %s: %s' + % (obj, submodname, e)) + raise name = getattr(obj, 'name', submodname) objs[name] = obj return objs @@ -121,7 +126,12 @@ def construct_graph(this_modname, submodnames, class_selector, for objname in dir(submod): obj = getattr(submod, objname) if class_selector(obj): - instance = obj() + try: + instance = obj() + except Exception, e: + logging.error('could not instantiate %s from %s: %s' + % (obj, submodname, e)) + raise if assert_name_match == True and instance.name != submodname: raise Exception( 'Instance name %s does not match module name %s' -- 2.26.2