File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed
Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -741,6 +741,12 @@ func (e ConnectionError) Origin() error {
741741 return e .err
742742}
743743
744+ // Unwrap returns the original error of this connection error or nil when the
745+ // origin is nil.
746+ func (e ConnectionError ) Unwrap () error {
747+ return e .err
748+ }
749+
744750var (
745751 // ErrConnClosing indicates that the transport is closing.
746752 ErrConnClosing = connectionErrorf (true , nil , "transport is closing" )
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ import (
2727 "io"
2828 "math"
2929 "net"
30+ "os"
3031 "runtime"
3132 "strconv"
3233 "strings"
@@ -2404,3 +2405,10 @@ func (s) TestClientDecodeHeaderStatusErr(t *testing.T) {
24042405 })
24052406 }
24062407}
2408+
2409+ func TestConnectionError_Unwrap (t * testing.T ) {
2410+ err := connectionErrorf (false , os .ErrNotExist , "unwrap me" )
2411+ if ! errors .Is (err , os .ErrNotExist ) {
2412+ t .Error ("ConnectionError does not unwrap" )
2413+ }
2414+ }
You can’t perform that action at this time.
0 commit comments