| 2333 | } |
| 2334 | |
| 2335 | func HasErrorCode(err error, codes ...ErrorCode) bool { |
| 2336 | if err == nil { |
| 2337 | return false |
| 2338 | } |
| 2339 | |
| 2340 | if be, ok := err.(StandardError); ok { |
| 2341 | return be.HasCode(codes...) |
| 2342 | } |
| 2343 | |
| 2344 | if be, ok := err.(*BaseError); ok { |
| 2345 | for _, code := range codes { |
| 2346 | if be.Code == code { |
| 2347 | return true |
| 2348 | } |
| 2349 | } |
| 2350 | } |
| 2351 | |
| 2352 | if arr, ok := err.(interface{ Unwrap() []error }); ok { |
| 2353 | for _, e := range arr.Unwrap() { |
| 2354 | if HasErrorCode(e, codes...) { |
| 2355 | return true |
| 2356 | } |
| 2357 | } |
| 2358 | } |
| 2359 | |
| 2360 | return false |
| 2361 | } |
| 2362 | |
| 2363 | // IsRetryableTowardNetwork reports whether err should be retried at network |
| 2364 | // scope (i.e. against a different upstream). Returns true by default; returns |