matchesTransientPattern reports whether the error's message matches one of [transientStatusCodePatterns]. Used to override an otherwise non-retryable HTTP status classification. Patterns are pre-lowercased (enforced by declaration convention) and additionally lowercased here for defence in depth, so
(err error)
| 366 | // declaration convention) and additionally lowercased here for defence in |
| 367 | // depth, so a mixed-case pattern slipping into the list will still match. |
| 368 | func matchesTransientPattern(err error) bool { |
| 369 | if err == nil { |
| 370 | return false |
| 371 | } |
| 372 | msg := strings.ToLower(err.Error()) |
| 373 | for _, p := range transientStatusCodePatterns { |
| 374 | if strings.Contains(msg, strings.ToLower(p)) { |
| 375 | return true |
| 376 | } |
| 377 | } |
| 378 | return false |
| 379 | } |
| 380 | |
| 381 | // retryablePatterns contains error message substrings that indicate a |
| 382 | // transient/retryable failure. Numeric status codes (500, 502, etc.) are |