Skip to content

Commit

Permalink
intercept netplugin std error
Browse files Browse the repository at this point in the history
  • Loading branch information
zjj2wry committed Dec 19, 2019
1 parent 46b9d6f commit bdd126b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/invoke/raw_exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,14 @@ func (e *RawExec) ExecPlugin(ctx context.Context, pluginPath string, stdinData [
}

func pluginErr(err error, output []byte) error {
if _, ok := err.(*exec.ExitError); ok {
if exitError, ok := err.(*exec.ExitError); ok {
emsg := types.Error{}
if len(output) == 0 {
emsg.Msg = "netplugin failed with no error message"
if len(exitError.Stderr) == 0 {
emsg.Msg = "netplugin failed with no error message"
} else {
emsg.Msg = fmt.Sprintf("netplugin failed: %q", string(exitError.Stderr))
}
} else if perr := json.Unmarshal(output, &emsg); perr != nil {
emsg.Msg = fmt.Sprintf("netplugin failed but error parsing its diagnostic message %q: %v", string(output), perr)
}
Expand Down

0 comments on commit bdd126b

Please sign in to comment.