Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bobgroup-go-utils
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Bob Public Utils
bobgroup-go-utils
Commits
74082d21
Commit
74082d21
authored
2 years ago
by
Francé Wilke
Browse files
Options
Downloads
Patches
Plain Diff
#34
Add new function for IsRetryableErrorOrShouldFail
parent
1bdc1482
No related branches found
No related tags found
1 merge request
!36
Resolve "Cater for errors being nil and update checks for retryable errors"
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
errors/error.go
+29
-3
29 additions, 3 deletions
errors/error.go
with
29 additions
and
3 deletions
errors/error.go
+
29
−
3
View file @
74082d21
...
...
@@ -263,10 +263,36 @@ func IsRetryableError(err error) bool {
return
true
}
// Explicitly check for and return false for any 400s as well
if
code
>=
400
&&
code
<
500
{
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
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment