IsForbiddenError reports whether err represents an HTTP 403 / "forbidden" response. It returns false when err is nil. The check is case-insensitive and only matches HTTP-style 403 patterns such as "HTTP 403" or "403 Forbidden", which avoids misclassifying unrelated errors like "forbidden character".
(err error)
| 29 | // "HTTP 403" or "403 Forbidden", which avoids misclassifying unrelated errors |
| 30 | // like "forbidden character". |
| 31 | func IsForbiddenError(err error) bool { |
| 32 | matched := containsHTTPStatusSubstring(err, "403", "forbidden") |
| 33 | if matched { |
| 34 | errorutilLog.Printf("Classified error as forbidden (403): %v", err) |
| 35 | } |
| 36 | return matched |
| 37 | } |
| 38 | |
| 39 | // IsGoneError reports whether err represents an HTTP 410 / "gone" response. |
| 40 | // It returns false when err is nil. |