| 180 | } |
| 181 | |
| 182 | func (m statusModel) statusRefreshRetryDelay(err error) (time.Duration, bool) { |
| 183 | var apiErr *api.APIError |
| 184 | if errors.As(err, &apiErr) { |
| 185 | switch { |
| 186 | case apiErr.StatusCode == http.StatusTooManyRequests: |
| 187 | if apiErr.HasRetryAfter { |
| 188 | return apiErr.RetryAfter, true |
| 189 | } |
| 190 | return 60 * time.Second, true |
| 191 | case apiErr.StatusCode >= 500: |
| 192 | return m.nextStatusPollDelay(), true |
| 193 | default: |
| 194 | return 0, false |
| 195 | } |
| 196 | } |
| 197 | |
| 198 | if errors.Is(err, api.ErrTransport) { |
| 199 | return m.nextStatusPollDelay(), true |
| 200 | } |
| 201 | |
| 202 | return 0, false |
| 203 | } |
| 204 | |
| 205 | func formatRetryDelay(delay time.Duration) string { |
| 206 | if delay <= 0 { |