diff --git a/errors/error.go b/errors/error.go index 65ac2fd02793002e19de920f21f877fd6a741554..d20acd5f24980a0574ec6e6ae2377b32f11a3c26 100644 --- a/errors/error.go +++ b/errors/error.go @@ -263,10 +263,36 @@ func IsRetryableError(err error) bool { return true } - // Explicitly check for and return false for any 400s as well + return false +} + +func IsRetryableErrorOrShouldFail(err error) (shouldRetry bool, shouldFail bool) { + if err == nil { + return false, false + } + + // Check for retryable + if IsRetryableError(err) { + return true, false + } + + code := HTTPCode(err) + + // If no HTTP code in the error, just fail but don't retry + if code == 0 { + return false, true + } + + // Explicitly check for 400s, and don't retry or fail if code >= 400 && code < 500 { - return false + return false, false } - return false + // Explicitly check for 200s, for a fail-safe + if code >= 200 && code < 300 { + return false, false + } + + // If we got here, we should fail normally + return false, true }