lang: ast, download: Improve error messages

This commit is contained in:
James Shubin
2024-11-28 17:12:15 -05:00
parent 98d7f294eb
commit e1070d3e13
3 changed files with 9 additions and 4 deletions

View File

@@ -3403,7 +3403,8 @@ func (obj *StmtProg) importScope(info *interfaces.ImportData, scope *interfaces.
if obj.data.Downloader != nil {
// run downloader stuff first
if err := obj.data.Downloader.Get(info, modulesPath); err != nil {
return nil, errwrap.Wrapf(err, "download of `%s` failed", info.Name)
obj.data.Logf("download of `%s` failed", info.Name)
return nil, err
}
}
@@ -3773,7 +3774,8 @@ func (obj *StmtProg) SetScope(scope *interfaces.Scope) error {
// run the scope importer...
importedScope, err := obj.importScope(result, scope)
if err != nil {
return errwrap.Wrapf(err, "import scope `%s` failed", imp.Name)
obj.data.Logf("import scope `%s` failed", imp.Name)
return err
}
// read from stored scope which was previously saved in SetScope

View File

@@ -86,7 +86,7 @@ func (obj *Downloader) Get(info *interfaces.ImportData, modulesPath string) erro
if err == nil {
return fmt.Errorf("module path (`%s`) must be a dir", modulesPath)
}
if err == os.ErrNotExist {
if os.IsNotExist(err) {
return fmt.Errorf("module path (`%s`) must exist", modulesPath)
}
return errwrap.Wrapf(err, "could not read module path (`%s`)", modulesPath)
@@ -164,6 +164,9 @@ func (obj *Downloader) Get(info *interfaces.ImportData, modulesPath string) erro
if err != nil && err != git.NoErrAlreadyUpToDate {
return errwrap.Wrapf(err, "can't pull latest from: `%s`", info.URL)
}
if err == git.NoErrAlreadyUpToDate {
obj.info.Logf("repo already up to date!")
}
}
// TODO: checkout requested sha1/tag if one was specified...

View File

@@ -19,4 +19,4 @@ print "unused" {
msg => "i'm unused because i'm inside an imported module",
}
-- OUTPUT --
# err: errSetScope: import scope `something.mcl` failed: local import of `something.mcl` failed: module contains unused statements: found stmt: res(print)
# err: errSetScope: local import of `something.mcl` failed: module contains unused statements: found stmt: res(print)