From bff29880d0709f7bf7dd065376175a1575005be4 Mon Sep 17 00:00:00 2001 From: Frank <35358771+Frankonly@users.noreply.github.com> Date: Fri, 9 Aug 2019 00:50:40 +0800 Subject: [PATCH] More user friendly ioctl error output (#1440) --- ioctl/output/format.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/ioctl/output/format.go b/ioctl/output/format.go index f7902a8259..acd8ebf93f 100644 --- a/ioctl/output/format.go +++ b/ioctl/output/format.go @@ -113,7 +113,7 @@ func (m *ErrorMessage) String() string { // Error implements error interface func (m ErrorMessage) Error() string { - return fmt.Sprintf("%d, %s", m.Code, m.Info) + return m.Info } // StringMessage is the Message for string @@ -181,13 +181,10 @@ func NewError(code ErrorCode, info string, pre error) error { // PrintError prints Error Message in format, only used at top layer of a command func PrintError(err error) error { - if err == nil { - return nil + if err == nil || Format == "" { + return err } newErr := NewError(0, "", err) - if Format == "" { - return newErr - } message := newErr.(ErrorMessage) fmt.Println(message.String()) return nil