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 moduleName = be.Value.ToString();
|
||||||
var module = _script.Options.ModuleHandler.GetModule(_script, moduleName);
|
var module = _script.Options.ModuleHandler.GetModule(_script, moduleName);
|
||||||
foreach (var moduleVariable in module.Scope.Variables)
|
if (module == null)
|
||||||
{
|
{
|
||||||
if (moduleVariable.Value.Local)
|
_diagnostics.LogError(
|
||||||
continue;
|
$"Can't find module '{moduleName}' in folder '{_script.Options.ScriptLoader.ModulesPath}'",
|
||||||
Scope.AssignToNearest(moduleVariable.Value);
|
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;
|
return module;
|
||||||
|
|
||||||
var moduleScript = script.Options.ScriptLoader.LoadModule(name);
|
var moduleScript = script.Options.ScriptLoader.LoadModule(name);
|
||||||
|
if (moduleScript == null)
|
||||||
|
return null;
|
||||||
var parsed = Executor.ContinueWith(script, moduleScript);
|
var parsed = Executor.ContinueWith(script, moduleScript);
|
||||||
module = parsed.Bind();
|
module = parsed.Bind();
|
||||||
_cachedModules.Add(name, module);
|
_cachedModules.Add(name, module);
|
||||||
|
|
|
@ -47,6 +47,10 @@ namespace Upsilon.StandardLibraries
|
||||||
{
|
{
|
||||||
var file = fileName.Value;
|
var file = fileName.Value;
|
||||||
var module = script.Options.ModuleHandler.GetModule(script, file);
|
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 s = Executor.ContinueWith(script, module);
|
||||||
var val = s.Evaluate();
|
var val = s.Evaluate();
|
||||||
return val != null ? val.ToScriptType() : new ScriptNull();
|
return val != null ? val.ToScriptType() : new ScriptNull();
|
||||||
|
|
Loading…
Reference in New Issue