Skip to content

Commit

Permalink
Merge pull request #3176 from dmcgowan/add-unwrap-to-custom-errors
Browse files Browse the repository at this point in the history
Add Unwrap error to custom error types
  • Loading branch information
thaJeztah authored Oct 12, 2024
2 parents ea1a7ce + 101f72b commit 508cebc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions agent/exec/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ type temporary struct {
error
}

func (t temporary) Unwrap() error { return t.error }
func (t temporary) Cause() error { return t.error }
func (t temporary) Temporary() bool { return true }

Expand Down
9 changes: 7 additions & 2 deletions swarmd/dockerexec/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ import (
engineapi "github.com/docker/docker/client"
"github.com/docker/go-connections/nat"
gogotypes "github.com/gogo/protobuf/types"
"github.com/pkg/errors"
"golang.org/x/time/rate"

"github.com/moby/swarmkit/v2/agent/exec"
"github.com/moby/swarmkit/v2/api"
"github.com/moby/swarmkit/v2/log"
"github.com/pkg/errors"
"golang.org/x/time/rate"
)

// controller implements agent.Controller against docker's API.
Expand Down Expand Up @@ -597,6 +598,10 @@ func (e *exitError) Cause() error {
return e.cause
}

func (e *exitError) Unwrap() error {
return e.cause
}

func makeExitError(ctnr types.ContainerJSON) error {
if ctnr.State.ExitCode != 0 {
var cause error
Expand Down

0 comments on commit 508cebc

Please sign in to comment.