From 44012b29ecbdc1f65f26c37c7804c14fb6b9b403 Mon Sep 17 00:00:00 2001 From: Matthew Hooker Date: Tue, 8 May 2018 03:25:00 -0700 Subject: [PATCH 1/3] Remove redundant error message. --- communicator/ssh/communicator.go | 1 - 1 file changed, 1 deletion(-) diff --git a/communicator/ssh/communicator.go b/communicator/ssh/communicator.go index 6545d1d5c..8fbddc968 100644 --- a/communicator/ssh/communicator.go +++ b/communicator/ssh/communicator.go @@ -335,7 +335,6 @@ func (c *comm) reconnect() (err error) { } if err != nil { - log.Printf("[ERROR] handshake error: %s", err) return } log.Printf("[DEBUG] handshake complete!") From 0a1842140bc404c3c15204da83e771c1ce1949b1 Mon Sep 17 00:00:00 2001 From: Matthew Hooker Date: Tue, 8 May 2018 04:06:03 -0700 Subject: [PATCH 2/3] Display build error when on-error=ask|abort --- common/multistep_runner.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/common/multistep_runner.go b/common/multistep_runner.go index e3c16e7cf..501e8b031 100644 --- a/common/multistep_runner.go +++ b/common/multistep_runner.go @@ -71,6 +71,10 @@ func (s abortStep) Run(ctx context.Context, state multistep.StateBag) multistep. } func (s abortStep) Cleanup(state multistep.StateBag) { + err, ok := state.GetOk("error") + if ok { + s.ui.Error(err.(error).Error()) + } if _, ok := state.GetOk(multistep.StateCancelled); ok { s.ui.Error("Interrupted, aborting...") os.Exit(1) @@ -99,6 +103,11 @@ func (s askStep) Run(ctx context.Context, state multistep.StateBag) (action mult return } + err, ok := state.GetOk("error") + if ok { + s.ui.Error(err.(error).Error()) + } + switch ask(s.ui, typeName(s.step), state) { case askCleanup: return From 5e6e12cacd01cee57dd30a30d52cb24fd3cdcd22 Mon Sep 17 00:00:00 2001 From: Matthew Hooker Date: Tue, 8 May 2018 15:21:54 -0700 Subject: [PATCH 3/3] Use fmt to convert whatever's in error to a string. This way we don't crash if someone sticks something else in the error key in the state bag (which a quick glance at the code tells me we're already doing. Perhaps in the future we can add an error attribute to the state bag but for now this will have to suffice. --- common/multistep_runner.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/multistep_runner.go b/common/multistep_runner.go index 501e8b031..b34ee3a04 100644 --- a/common/multistep_runner.go +++ b/common/multistep_runner.go @@ -73,7 +73,7 @@ func (s abortStep) Run(ctx context.Context, state multistep.StateBag) multistep. func (s abortStep) Cleanup(state multistep.StateBag) { err, ok := state.GetOk("error") if ok { - s.ui.Error(err.(error).Error()) + s.ui.Error(fmt.Sprintf("%s", err)) } if _, ok := state.GetOk(multistep.StateCancelled); ok { s.ui.Error("Interrupted, aborting...") @@ -105,7 +105,7 @@ func (s askStep) Run(ctx context.Context, state multistep.StateBag) (action mult err, ok := state.GetOk("error") if ok { - s.ui.Error(err.(error).Error()) + s.ui.Error(fmt.Sprintf("%s", err)) } switch ask(s.ui, typeName(s.step), state) {