Skip to content

Commit ef0f6fa

Browse files
authored
Merge pull request #24 from nao1215/improvement-error-msg
Improved error messages
2 parents c795a04 + fd94fd6 commit ef0f6fa

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ All notable changes to this project will be documented in this file. The format
55
## Changed
66
- Parallelized update process
77
- Simplified messages during the update process
8+
- Improved error messages
89
# [0.9.1] - 2022-03-19
910
## Changed
1011
- Changed the message at the time of update was incorrect, so the message was corrected.

cmd/update.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,10 @@ func update(pkgs []goutil.Package, dryRun bool) int {
8383
updater := func(p goutil.Package, result chan updateResult) {
8484
var err error
8585
if p.ImportPath == "" {
86-
err = fmt.Errorf(" %s", p.Name)
86+
err = fmt.Errorf(" %s is not installed by 'go install' (or permission incorrect)", p.Name)
8787
} else {
8888
if err = goutil.Install(p.ImportPath); err != nil {
89-
err = fmt.Errorf(" %w: %s", err, p.Name)
89+
err = fmt.Errorf(" %s %w", p.Name, err)
9090
}
9191
}
9292

internal/goutil/goutil.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,10 @@ func CanUseGoCmd() error {
151151
// Install execute "$ go install <importPath>@latest"
152152
func Install(importPath string) error {
153153
if importPath == "command-line-arguments" {
154-
return errors.New("this is devel-binary copied from local environment")
154+
return errors.New("is devel-binary copied from local environment")
155155
}
156156
if err := exec.Command("go", "install", importPath+"@latest").Run(); err != nil {
157-
return errors.New("can't install " + importPath)
157+
return fmt.Errorf("can't install %s: %w", importPath, err)
158158
}
159159
return nil
160160
}

0 commit comments

Comments
 (0)