
On Thu, 2015-10-29 at 18:48 -0200, dhbarboza82@gmail.com wrote:
From: Daniel Henrique Barboza <dhbarboza82@gmail.com>
Error messages in WoK boot-up process weren't being forwarded to the user, making it harder to detect the cause of the failure.
Signed-off-by: Daniel Henrique Barboza <dhbarboza82@gmail.com> --- src/wok/server.py | 17 ++++++++++------- src/wok/utils.py | 7 +++++-- 2 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/src/wok/server.py b/src/wok/server.py index c6f12dd..59ecdc0 100644 --- a/src/wok/server.py +++ b/src/wok/server.py @@ -158,9 +158,11 @@ class Server(object):
try: plugin_app = import_class(plugin_class)(options) - except ImportError: - cherrypy.log.error_log.error("Failed to import plugin %s" % - plugin_class) + except ImportError, e: + cherrypy.log.error_log.error( + "Failed to import plugin %s, " + "error: %s" % (plugin_class, e.message) + ) continue
# dynamically extend plugin config with custom data, if provided @@ -173,10 +175,11 @@ class Server(object): try: authed_apis = import_class(('plugins.%s.%s' % (plugin_name, extra_auth))) - except ImportError: - cherrypy.log.error_log.error("Failed to import subnodes " - "for plugin %s" % - plugin_class) + except ImportError, e: + cherrypy.log.error_log.error( + "Failed to import subnodes for plugin %s, " + "error: %s" % (plugin_class, e.message) + )
+1 Much needed change.
continue
urlSubNodes = {} diff --git a/src/wok/utils.py b/src/wok/utils.py index ccc8534..74c521f 100644 --- a/src/wok/utils.py +++ b/src/wok/utils.py @@ -114,8 +114,11 @@ def import_class(class_path): try: mod = import_module(module_name, class_name) return getattr(mod, class_name) - except (ImportError, AttributeError): - raise ImportError('Class %s can not be imported' % class_path) + except (ImportError, AttributeError), e: + raise ImportError( + 'Class %s can not be imported, ' + 'error: %s' % (class_path, e.message) + )
def import_module(module_name, class_name=''):