mirror of
https://github.com/diamondburned/arikawa.git
synced 2025-02-11 05:52:58 +00:00
Merge pull request #26 from mavolin/25-retries-on-error
This commit is contained in:
commit
107c6a6563
|
@ -8,11 +8,15 @@ import (
|
|||
"io"
|
||||
"mime/multipart"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/diamondburned/arikawa/utils/httputil/httpdriver"
|
||||
"github.com/diamondburned/arikawa/utils/json"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// StatusTooManyRequests is the HTTP status code discord sends on rate-limiting.
|
||||
const StatusTooManyRequests = 429
|
||||
|
||||
// Retries is the default attempts to retry if the API returns an error before
|
||||
// giving up. If the value is smaller than 1, then requests will retry forever.
|
||||
var Retries uint = 5
|
||||
|
@ -179,7 +183,7 @@ func (c *Client) Request(method, url string, opts ...RequestOption) (httpdriver.
|
|||
continue
|
||||
}
|
||||
|
||||
if status = r.GetStatus(); status < 200 || status > 299 {
|
||||
if status = r.GetStatus(); status == StatusTooManyRequests || status >= 500 {
|
||||
continue
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue