diff --git a/goblin/driver/cluster.py b/goblin/driver/cluster.py index 5ef5059618c7ee53215941219f656a78cf2c313a..b0ca5900088d27636d7034ff18436e37e4698da3 100644 --- a/goblin/driver/cluster.py +++ b/goblin/driver/cluster.py @@ -32,8 +32,15 @@ from goblin import driver, exception, provider def my_import(name): - module_name, class_name = name.rsplit('.', maxsplit=1) - module = importlib.import_module(module_name) + names = name.rsplit('.', maxsplit=1) + if len(names) != 2: + raise exception.ConfigError("not a valid absolute python path to a class: {}".format(name)) + module_name, class_name = names + try: + module = importlib.import_module(module_name) + except ImportError: + raise exception.ConfigError( + "Error processing cluster configuration: could not import {}".format(name)) return getattr(module, class_name) diff --git a/goblin/exception.py b/goblin/exception.py index 203102b9e8db4217ac6903fc63ccb9492402b011..46cf2e645c438b2dab7eadd2b7dcd8e66acbe3d3 100644 --- a/goblin/exception.py +++ b/goblin/exception.py @@ -16,6 +16,10 @@ # along with Goblin. If not, see <http://www.gnu.org/licenses/>. +class ConfigError(Exception): + pass + + class ClientError(Exception): pass