containsErrorSubstring reports whether err contains any of the provided substrings after lowercasing the full error message for case-insensitive matching.
(err error, substrings ...string)
| 53 | // substrings after lowercasing the full error message for case-insensitive |
| 54 | // matching. |
| 55 | func containsErrorSubstring(err error, substrings ...string) bool { |
| 56 | if err == nil { |
| 57 | return false |
| 58 | } |
| 59 | msg := strings.ToLower(err.Error()) |
| 60 | for _, substring := range substrings { |
| 61 | if strings.Contains(msg, substring) { |
| 62 | return true |
| 63 | } |
| 64 | } |
| 65 | return false |
| 66 | } |
| 67 | |
| 68 | // containsHTTPStatusSubstring reports whether err contains a recognized |
| 69 | // HTTP-style status pattern for the provided status code and keyword. |
no test coverage detected