Skip to content

Commit

Permalink
Merge pull request #406 from GheRivero/cni_error
Browse files Browse the repository at this point in the history
Return cni.type.Error instead of plain error
  • Loading branch information
Casey Callendrello authored Jun 8, 2017
2 parents 6828d6c + e00a647 commit 2d3fa84
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 2 additions & 6 deletions pkg/invoke/raw_exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,9 @@ func pluginErr(err error, output []byte) error {
if _, ok := err.(*exec.ExitError); ok {
emsg := types.Error{}
if perr := json.Unmarshal(output, &emsg); perr != nil {
return fmt.Errorf("netplugin failed but error parsing its diagnostic message %q: %v", string(output), perr)
emsg.Msg = fmt.Sprintf("netplugin failed but error parsing its diagnostic message %q: %v", string(output), perr)
}
details := ""
if emsg.Details != "" {
details = fmt.Sprintf("; %v", emsg.Details)
}
return fmt.Errorf("%v%v", emsg.Msg, details)
return &emsg
}

return err
Expand Down
6 changes: 5 additions & 1 deletion pkg/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,11 @@ type Error struct {
}

func (e *Error) Error() string {
return e.Msg
details := ""
if e.Details != "" {
details = fmt.Sprintf("; %v", e.Details)
}
return fmt.Sprintf("%v%v", e.Msg, details)
}

func (e *Error) Print() error {
Expand Down

0 comments on commit 2d3fa84

Please sign in to comment.