Skip to content

Commit

Permalink
More user friendly ioctl error output (#1440)
Browse files Browse the repository at this point in the history
  • Loading branch information
Frankonly authored Aug 8, 2019
1 parent 6bbe963 commit bff2988
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions ioctl/output/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit bff2988

Please sign in to comment.