diff --git a/Changelog.md b/Changelog.md index 8c927c8..7482ef3 100644 --- a/Changelog.md +++ b/Changelog.md @@ -5,6 +5,7 @@ All notable changes to this project will be documented in this file. The format ## Changed - Parallelized update process - Simplified messages during the update process +- Improved error messages # [0.9.1] - 2022-03-19 ## Changed - Changed the message at the time of update was incorrect, so the message was corrected. diff --git a/cmd/update.go b/cmd/update.go index 9cbb055..9fb22bb 100644 --- a/cmd/update.go +++ b/cmd/update.go @@ -83,10 +83,10 @@ func update(pkgs []goutil.Package, dryRun bool) int { updater := func(p goutil.Package, result chan updateResult) { var err error if p.ImportPath == "" { - err = fmt.Errorf(" %s", p.Name) + err = fmt.Errorf(" %s is not installed by 'go install' (or permission incorrect)", p.Name) } else { if err = goutil.Install(p.ImportPath); err != nil { - err = fmt.Errorf(" %w: %s", err, p.Name) + err = fmt.Errorf(" %s %w", p.Name, err) } } diff --git a/internal/goutil/goutil.go b/internal/goutil/goutil.go index 86c2ade..06bff1b 100644 --- a/internal/goutil/goutil.go +++ b/internal/goutil/goutil.go @@ -151,10 +151,10 @@ func CanUseGoCmd() error { // Install execute "$ go install @latest" func Install(importPath string) error { if importPath == "command-line-arguments" { - return errors.New("this is devel-binary copied from local environment") + return errors.New("is devel-binary copied from local environment") } if err := exec.Command("go", "install", importPath+"@latest").Run(); err != nil { - return errors.New("can't install " + importPath) + return fmt.Errorf("can't install %s: %w", importPath, err) } return nil }