Skip to content
Snippets Groups Projects
Commit 74082d21 authored by Francé Wilke's avatar Francé Wilke
Browse files

#34 Add new function for IsRetryableErrorOrShouldFail

parent 1bdc1482
No related branches found
No related tags found
1 merge request!36Resolve "Cater for errors being nil and update checks for retryable errors"
This commit is part of merge request !36. Comments created here will be created in the context of that merge request.
...@@ -263,10 +263,36 @@ func IsRetryableError(err error) bool { ...@@ -263,10 +263,36 @@ func IsRetryableError(err error) bool {
return true return true
} }
// Explicitly check for and return false for any 400s as well
if code >= 400 && code < 500 {
return false return false
} }
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, 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
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment