Better error reporting if unable to find module
This commit is contained in:
parent
c1da2dd5b7
commit
edd352e62a
|
@ -248,11 +248,20 @@ namespace Upsilon.Binder
|
|||
{
|
||||
var moduleName = be.Value.ToString();
|
||||
var module = _script.Options.ModuleHandler.GetModule(_script, moduleName);
|
||||
foreach (var moduleVariable in module.Scope.Variables)
|
||||
if (module == null)
|
||||
{
|
||||
if (moduleVariable.Value.Local)
|
||||
continue;
|
||||
Scope.AssignToNearest(moduleVariable.Value);
|
||||
_diagnostics.LogError(
|
||||
$"Can't find module '{moduleName}' in folder '{_script.Options.ScriptLoader.ModulesPath}'",
|
||||
parameter.Span);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var moduleVariable in module.Scope.Variables)
|
||||
{
|
||||
if (moduleVariable.Value.Local)
|
||||
continue;
|
||||
Scope.AssignToNearest(moduleVariable.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,8 @@ namespace Upsilon
|
|||
return module;
|
||||
|
||||
var moduleScript = script.Options.ScriptLoader.LoadModule(name);
|
||||
if (moduleScript == null)
|
||||
return null;
|
||||
var parsed = Executor.ContinueWith(script, moduleScript);
|
||||
module = parsed.Bind();
|
||||
_cachedModules.Add(name, module);
|
||||
|
|
|
@ -47,6 +47,10 @@ namespace Upsilon.StandardLibraries
|
|||
{
|
||||
var file = fileName.Value;
|
||||
var module = script.Options.ModuleHandler.GetModule(script, file);
|
||||
if (module == null)
|
||||
{
|
||||
throw new Exception($"Unable to load module {file} at path {script.Options.ScriptLoader.ModulesPath}");
|
||||
}
|
||||
var s = Executor.ContinueWith(script, module);
|
||||
var val = s.Evaluate();
|
||||
return val != null ? val.ToScriptType() : new ScriptNull();
|
||||
|
|
Loading…
Reference in New Issue