Skip to content

Commit af52cdb

Browse files
authored
PLM-172: Fix transient error check (#123)
1 parent 3a9b010 commit af52cdb

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

topo/errors.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,23 +85,23 @@ func IsTransient(err error) bool {
8585
var wEx mongo.WriteException
8686
if errors.As(err, &wEx) {
8787
for _, we := range wEx.WriteErrors {
88-
_, ok := transientErrorCodes[we.Code]
89-
90-
return ok
88+
if _, ok := transientErrorCodes[we.Code]; ok {
89+
return true
90+
}
9191
}
9292

9393
if wEx.WriteConcernError != nil {
94-
_, ok := transientErrorCodes[wEx.WriteConcernError.Code]
95-
96-
return ok
94+
if _, ok := transientErrorCodes[wEx.WriteConcernError.Code]; ok {
95+
return true
96+
}
9797
}
9898
}
9999

100100
var cmdErr mongo.CommandError
101101
if errors.As(err, &cmdErr) {
102-
_, ok := transientErrorCodes[int(cmdErr.Code)]
103-
104-
return ok
102+
if _, ok := transientErrorCodes[int(cmdErr.Code)]; ok {
103+
return true
104+
}
105105
}
106106

107107
return false

0 commit comments

Comments
 (0)