Skip to content

Commit 101f72b

Browse files
committed
Add Unwrap error to custom error types
Signed-off-by: Derek McGowan <[email protected]>
1 parent c1c857e commit 101f72b

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

agent/exec/errors.go

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ type temporary struct {
6464
error
6565
}
6666

67+
func (t temporary) Unwrap() error { return t.error }
6768
func (t temporary) Cause() error { return t.error }
6869
func (t temporary) Temporary() bool { return true }
6970

swarmd/dockerexec/controller.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ import (
1616
engineapi "github.com/docker/docker/client"
1717
"github.com/docker/go-connections/nat"
1818
gogotypes "github.com/gogo/protobuf/types"
19+
"github.com/pkg/errors"
20+
"golang.org/x/time/rate"
21+
1922
"github.com/moby/swarmkit/v2/agent/exec"
2023
"github.com/moby/swarmkit/v2/api"
2124
"github.com/moby/swarmkit/v2/log"
22-
"github.com/pkg/errors"
23-
"golang.org/x/time/rate"
2425
)
2526

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

601+
func (e *exitError) Unwrap() error {
602+
return e.cause
603+
}
604+
600605
func makeExitError(ctnr types.ContainerJSON) error {
601606
if ctnr.State.ExitCode != 0 {
602607
var cause error

0 commit comments

Comments
 (0)