aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElliott Sales de Andrade <quantum.analyst@gmail.com>2017-04-15 20:38:53 -0400
committerJussi Pakkanen <jpakkane@gmail.com>2017-04-17 12:43:57 +0300
commita57f441b37fbabd96f35759c22f571bf39a7c9e3 (patch)
treec48e1a952204b401ddb2ceb43ca35b346d8a868e
parent5b917a6e174123be547ca9e55a280684410f291f (diff)
downloadmeson-a57f441b37fbabd96f35759c22f571bf39a7c9e3.zip
meson-a57f441b37fbabd96f35759c22f571bf39a7c9e3.tar.gz
meson-a57f441b37fbabd96f35759c22f571bf39a7c9e3.tar.bz2
Raise clear error if module name doesn't exist.
Don't raise a full backtrace.
-rw-r--r--mesonbuild/interpreter.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index d00338b..649b842 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -1403,8 +1403,11 @@ class Interpreter(InterpreterBase):
raise InvalidCode('Import takes one argument.')
modname = args[0]
if modname not in self.environment.coredata.modules:
- module = importlib.import_module('mesonbuild.modules.' + modname).initialize()
- self.environment.coredata.modules[modname] = module
+ try:
+ module = importlib.import_module('mesonbuild.modules.' + modname)
+ except ImportError:
+ raise InvalidArguments('Module "%s" does not exist' % (modname, ))
+ self.environment.coredata.modules[modname] = module.initialize()
return ModuleHolder(modname, self.environment.coredata.modules[modname], self)
@stringArgs