diff --git a/core/commands/add.go b/core/commands/add.go index 894c987956d..e96986f109a 100644 --- a/core/commands/add.go +++ b/core/commands/add.go @@ -453,19 +453,8 @@ You can now check what blocks have been created by: for { v, err := res.Next() - if err != nil { - // replace error by actual error - will be looked at by next if-statement - if err == cmds.ErrRcvdError { - err = res.Error() - } - - if e, ok := err.(*cmdkit.Error); ok { - re.Emit(e) - } else if err != io.EOF { - re.SetError(err, cmdkit.ErrNormal) - } - - return + if !cmds.HandleError(err, res, re) { + break } select { diff --git a/core/commands/get.go b/core/commands/get.go index 91c6bf6a7ef..a64e1629a91 100644 --- a/core/commands/get.go +++ b/core/commands/get.go @@ -109,8 +109,7 @@ may also specify the level of compression by specifying '-l=<1-9>'. defer re.Close() v, err := res.Next() - if err != nil { - log.Error(e.New(err)) + if !cmds.HandleError(err, res, re) { return }