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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Bob Public Utils
bobgroup-go-utils
Commits
c40276b1
Commit
c40276b1
authored
2 years ago
by
Francé Wilke
Browse files
Options
Downloads
Patches
Plain Diff
Add IsRetryableError function
parent
e16d1c9d
Branches
Branches containing commit
Tags
v1.44.0
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
errors/error.go
+50
-32
50 additions, 32 deletions
errors/error.go
errors/errors.go
+2
-3
2 additions, 3 deletions
errors/errors.go
with
52 additions
and
35 deletions
errors/error.go
+
50
−
32
View file @
c40276b1
...
@@ -2,6 +2,7 @@ package errors
...
@@ -2,6 +2,7 @@ package errors
import
(
import
(
"fmt"
"fmt"
"net/http"
"path"
"path"
"strconv"
"strconv"
"strings"
"strings"
...
@@ -242,3 +243,20 @@ func pkgDescription(level int, err error) *Description {
...
@@ -242,3 +243,20 @@ func pkgDescription(level int, err error) *Description {
}
// if has stack
}
// if has stack
return
desc
return
desc
}
}
func
IsRetryableError
(
err
error
)
bool
{
code
:=
HTTPCode
(
err
)
// 429 should always retry
if
code
==
http
.
StatusTooManyRequests
{
return
true
}
// Retry for all except 200s and 400s
if
code
<
200
||
(
code
>=
300
&&
code
<
400
)
||
code
>
500
{
return
true
}
return
false
}
This diff is collapsed.
Click to expand it.
errors/errors.go
+
2
−
3
View file @
c40276b1
...
@@ -2,7 +2,6 @@ package errors
...
@@ -2,7 +2,6 @@ package errors
import
(
import
(
"fmt"
"fmt"
pkg_errors
"github.com/pkg/errors"
pkg_errors
"github.com/pkg/errors"
)
)
...
...
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