From e03686f9612f2a31fae0a7223037b7eb4ef17199 Mon Sep 17 00:00:00 2001 From: Sergei Trofimov Date: Mon, 13 Apr 2015 08:25:56 +0100 Subject: [PATCH] Improve error repoting when loading extensions The error message will now contain the offending extension (either package name or full path to extension file) if a Python error occurs when ExtensionLoader attempts to load it. --- wlauto/core/extension_loader.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/wlauto/core/extension_loader.py b/wlauto/core/extension_loader.py index 0263f830..e82260e1 100644 --- a/wlauto/core/extension_loader.py +++ b/wlauto/core/extension_loader.py @@ -304,8 +304,8 @@ class ExtensionLoader(object): for module in walk_modules(package): self._load_module(module) except ImportError as e: - message = 'Problem loading extensions from extra packages: {}' - raise LoaderError(message.format(e.message)) + message = 'Problem loading extensions from package {}: {}' + raise LoaderError(message.format(package, e.message)) def _load_from_paths(self, paths, ignore_paths): self.logger.debug('Loading from paths.') @@ -333,6 +333,9 @@ class ExtensionLoader(object): self.logger.warn('Got: {}'.format(e)) else: raise LoaderError('Failed to load {}'.format(filepath), sys.exc_info()) + except Exception as e: + message = 'Problem loading extensions from {}: {}' + raise LoaderError(message.format(filepath, e)) def _load_module(self, module): # NOQA pylint: disable=too-many-branches self.logger.debug('Checking module %s', module.__name__)