Skip to content

Commit dc073c9

Browse files
committed
cmd/get: More concise error output
getParallelResult's "status" and "err" have duplicate information. It is hard to see what's real cause if these information are output twice.
1 parent fa2bf3a commit dc073c9

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

cmd/get.go

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,8 @@ type getParallelResult struct {
293293
const (
294294
statusPrefixFailed = "!"
295295
// Failed
296-
fmtInstallFailed = "! %s > install failed > %s"
297-
fmtUpgradeFailed = "! %s > upgrade failed > %s"
296+
fmtInstallFailed = "! %s > install failed"
297+
fmtUpgradeFailed = "! %s > upgrade failed"
298298
// No change
299299
fmtNoChange = "# %s > no change"
300300
fmtAlreadyExists = "# %s > already exists"
@@ -343,7 +343,7 @@ func (cmd *getCmd) installPlugin(reposPath pathutil.ReposPath, repos *lockjson.R
343343
}
344344
done <- getParallelResult{
345345
reposPath: reposPath,
346-
status: fmt.Sprintf(fmtInstallFailed, reposPath, result.Error()),
346+
status: fmt.Sprintf(fmtInstallFailed, reposPath),
347347
err: result,
348348
}
349349
return
@@ -357,11 +357,10 @@ func (cmd *getCmd) installPlugin(reposPath pathutil.ReposPath, repos *lockjson.R
357357
if doUpgrade {
358358
// when cmd.upgrade is true, repos must not be nil.
359359
if repos == nil {
360-
msg := "-u was specified but repos == nil"
361360
done <- getParallelResult{
362361
reposPath: reposPath,
363-
status: fmt.Sprintf(fmtUpgradeFailed, reposPath, msg),
364-
err: errors.New("failed to upgrade plugin: " + msg),
362+
status: fmt.Sprintf(fmtUpgradeFailed, reposPath),
363+
err: errors.New("failed to upgrade plugin: -u was specified but repos == nil"),
365364
}
366365
return
367366
}
@@ -377,7 +376,7 @@ func (cmd *getCmd) installPlugin(reposPath pathutil.ReposPath, repos *lockjson.R
377376
}
378377
done <- getParallelResult{
379378
reposPath: reposPath,
380-
status: fmt.Sprintf(fmtUpgradeFailed, reposPath, result.Error()),
379+
status: fmt.Sprintf(fmtUpgradeFailed, reposPath),
381380
err: result,
382381
}
383382
return
@@ -400,7 +399,7 @@ func (cmd *getCmd) installPlugin(reposPath pathutil.ReposPath, repos *lockjson.R
400399
}
401400
done <- getParallelResult{
402401
reposPath: reposPath,
403-
status: fmt.Sprintf(fmtInstallFailed, reposPath, result.Error()),
402+
status: fmt.Sprintf(fmtInstallFailed, reposPath),
404403
err: result,
405404
}
406405
return
@@ -425,7 +424,7 @@ func (cmd *getCmd) installPlugin(reposPath pathutil.ReposPath, repos *lockjson.R
425424
}
426425
done <- getParallelResult{
427426
reposPath: reposPath,
428-
status: fmt.Sprintf(fmtInstallFailed, reposPath, result.Error()),
427+
status: fmt.Sprintf(fmtInstallFailed, reposPath),
429428
err: result,
430429
}
431430
return
@@ -466,7 +465,7 @@ func (cmd *getCmd) installPlugconf(reposPath pathutil.ReposPath, pluginResult *g
466465
}
467466
done <- getParallelResult{
468467
reposPath: reposPath,
469-
status: fmt.Sprintf(fmtInstallFailed, reposPath, result.Error()),
468+
status: fmt.Sprintf(fmtInstallFailed, reposPath),
470469
err: result,
471470
}
472471
return

cmd/get_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ func TestErrVoltGetNotFound(t *testing.T) {
459459
}
460460

461461
// (H)
462-
msg := fmt.Sprintf(fmtInstallFailed, reposPath, "")
462+
msg := fmt.Sprintf(fmtInstallFailed, reposPath)
463463
if !bytes.Contains(out, []byte(msg)) {
464464
t.Errorf("Output does not contain %q\n%s", msg, string(out))
465465
}

0 commit comments

Comments
 (0)