Better error reporting if unable to find module
This commit is contained in:
parent
c1da2dd5b7
commit
edd352e62a
|
@ -248,6 +248,14 @@ namespace Upsilon.Binder
|
|||
{
|
||||
var moduleName = be.Value.ToString();
|
||||
var module = _script.Options.ModuleHandler.GetModule(_script, moduleName);
|
||||
if (module == null)
|
||||
{
|
||||
_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)
|
||||
|
@ -257,6 +265,7 @@ namespace Upsilon.Binder
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
returnType = function.ResultType;
|
||||
|
||||
|
|
|
@ -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