Skip to content

Commit 1663911

Browse files
author
Romain Dartigues
committed
Type assertion on errors fails on wrapped errors
1 parent 1060966 commit 1663911

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

retrywrapper.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"code.cloudfoundry.org/cli/api/cloudcontroller"
66
"code.cloudfoundry.org/cli/api/cloudcontroller/ccerror"
77
"code.cloudfoundry.org/cli/api/router"
8+
"errors"
89
"io"
910
"net/http"
1011
"reflect"
@@ -59,7 +60,8 @@ func (retry *RetryRequest) Make(request *cloudcontroller.Request, passedResponse
5960
if reader, ok := request.Body.(io.ReadSeeker); ok {
6061
_, resetErr := reader.Seek(0, 0)
6162
if resetErr != nil {
62-
if _, ok := resetErr.(ccerror.PipeSeekError); ok {
63+
var pipeSeekError ccerror.PipeSeekError
64+
if errors.As(resetErr, &pipeSeekError) {
6365
return ccerror.PipeSeekError{Err: err}
6466
}
6567
return resetErr
@@ -130,7 +132,8 @@ func (retry *retryRequestRouter) Make(request *router.Request, passedResponse *r
130132
if reader, ok := request.Body.(io.ReadSeeker); ok {
131133
_, resetErr := reader.Seek(0, 0)
132134
if resetErr != nil {
133-
if _, ok := resetErr.(ccerror.PipeSeekError); ok {
135+
var pipeSeekError ccerror.PipeSeekError
136+
if errors.As(resetErr, &pipeSeekError) {
134137
return ccerror.PipeSeekError{Err: err}
135138
}
136139
return resetErr

0 commit comments

Comments
 (0)