From eb5f478ee7d8fdd6a2994a9cc4ca773ef36c2214 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 24 May 2013 09:27:28 -0700 Subject: [PATCH] communicator/ssh: Return error if non-zero exit status on Upload --- communicator/ssh/communicator.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/communicator/ssh/communicator.go b/communicator/ssh/communicator.go index 88a7ec66a..75a9cd5bb 100644 --- a/communicator/ssh/communicator.go +++ b/communicator/ssh/communicator.go @@ -137,15 +137,13 @@ func (c *comm) Upload(path string, input io.Reader) error { // our data and has completed. Or has errored. err = session.Wait() if err != nil { - exitErr, ok := err.(*ssh.ExitError) - if !ok { - // This wasn't an exit error, so something fatal happened - return err + if exitErr, ok := err.(*ssh.ExitError); ok { + // Otherwise, we have an ExitErorr, meaning we can just read + // the exit status + log.Printf("non-zero exit status: %d", exitErr.ExitStatus()) } - // Otherwise, we have an ExitErorr, meaning we can just read - // the exit status - log.Printf("exit status: %d", exitErr.ExitStatus()) + return err }