Skip to content

Commit

Permalink
fix(portforward): properly use errors.As (#254)
Browse files Browse the repository at this point in the history
`exec.ExitError` only implements the `error` interface if it is a
pointer (`Error()` is a pointer reciever). So, in order to use
`errors.As` we need to also set `exitError` to be `*exec.ExitError`.

Fixes #252
  • Loading branch information
jaredallard authored Aug 17, 2023
1 parent e763670 commit 540fd4a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion internal/proxier/portforward.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ func (w *worker) stopPortForward(ctx context.Context, conn *PortForwardConnectio
args := []string{"lo0", "-alias", ipStr}
if err := exec.Command("ifconfig", args...).Run(); err != nil {
message := ""
var exitError exec.ExitError
var exitError *exec.ExitError
if ok := errors.As(err, &exitError); ok {
message = string(exitError.Stderr)
}
Expand Down

0 comments on commit 540fd4a

Please sign in to comment.