File tree Expand file tree Collapse file tree 2 files changed +31
-4
lines changed Expand file tree Collapse file tree 2 files changed +31
-4
lines changed Original file line number Diff line number Diff line change @@ -314,9 +314,9 @@ func (e vsockAckError) Temporary() bool {
314
314
// error, according to the interface defined here:
315
315
// https://golang.org/pkg/net/#Error
316
316
func isTemporaryNetErr (err error ) bool {
317
- terr , ok := err .( interface {
317
+ type tempError interface {
318
318
Temporary () bool
319
- })
320
-
321
- return err != nil && ok && terr .Temporary ()
319
+ }
320
+ var terr tempError
321
+ return err != nil && errors . As ( err , & terr ) && terr .Temporary ()
322
322
}
Original file line number Diff line number Diff line change
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License"). You may
4
+ // not use this file except in compliance with the License. A copy of the
5
+ // License is located at
6
+ //
7
+ // http://aws.amazon.com/apache2.0/
8
+ //
9
+ // or in the "license" file accompanying this file. This file is distributed
10
+ // on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11
+ // express or implied. See the License for the specific language governing
12
+ // permissions and limitations under the License.
13
+
14
+ package vm
15
+
16
+ import (
17
+ "errors"
18
+ "testing"
19
+
20
+ "github.com/stretchr/testify/assert"
21
+ )
22
+
23
+ func TestTemporaryNetErr (t * testing.T ) {
24
+ assert .False (t , isTemporaryNetErr (nil ))
25
+ assert .False (t , isTemporaryNetErr (errors .New ("hello" )))
26
+ assert .True (t , isTemporaryNetErr (& vsockAckError {cause : errors .New ("hello" )}))
27
+ }
You can’t perform that action at this time.
0 commit comments