File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -89,8 +89,7 @@ func (e *Error) Temporary() bool {
8989 return false
9090 }
9191 for _ , d := range e .Errors {
92- // TODO: Include other error types.
93- if d .Code != BlobUploadInvalidErrorCode {
92+ if _ , ok := temporaryErrorCodes [d .Code ]; ! ok {
9493 return false
9594 }
9695 }
@@ -149,8 +148,15 @@ const (
149148 UnauthorizedErrorCode ErrorCode = "UNAUTHORIZED"
150149 DeniedErrorCode ErrorCode = "DENIED"
151150 UnsupportedErrorCode ErrorCode = "UNSUPPORTED"
151+ TooManyRequestsErrorCode ErrorCode = "TOOMANYREQUESTS"
152152)
153153
154+ // TODO: Include other error types.
155+ var temporaryErrorCodes = map [ErrorCode ]struct {}{
156+ BlobUploadInvalidErrorCode : struct {}{},
157+ TooManyRequestsErrorCode : struct {}{},
158+ }
159+
154160// CheckError returns a structured error if the response status is not in codes.
155161func CheckError (resp * http.Response , codes ... int ) error {
156162 for _ , code := range codes {
Original file line number Diff line number Diff line change @@ -50,6 +50,13 @@ func TestTemporary(t *testing.T) {
5050 }},
5151 },
5252 retry : false ,
53+ }, {
54+ error : & Error {
55+ Errors : []Diagnostic {{
56+ Code : TooManyRequestsErrorCode ,
57+ }},
58+ },
59+ retry : true ,
5360 }}
5461
5562 for _ , test := range tests {
You can’t perform that action at this time.
0 commit comments