Handle compile errors in imported modules.

This commit is contained in:
Bob Nystrom
2015-12-08 07:49:37 -08:00
parent bfa86b259a
commit 2df5362ab2
5 changed files with 21 additions and 7 deletions
+7 -2
View File
@@ -506,12 +506,17 @@ static Value importModule(WrenVM* vm, Value name)
char* source = vm->config.loadModuleFn(vm, AS_CSTRING(name));
if (source == NULL)
{
// Couldn't load the module.
vm->fiber->error = wrenStringFormat(vm, "Could not find module '@'.", name);
vm->fiber->error = wrenStringFormat(vm, "Could not load module '@'.", name);
return NULL_VAL;
}
ObjFiber* moduleFiber = loadModule(vm, name, source);
if (moduleFiber == NULL)
{
vm->fiber->error = wrenStringFormat(vm,
"Could not compile module '@'.", name);
return NULL_VAL;
}
// Return the fiber that executes the module.
return OBJ_VAL(moduleFiber);