Skip to content

Latest commit

 

History

History
38 lines (29 loc) · 556 Bytes

File metadata and controls

38 lines (29 loc) · 556 Bytes

Errors and Retries

Cloudflare errors are returned as *d1http.APIError.

_, err := client.Raw(ctx, "INVALID SQL")
var apiErr *d1http.APIError
if errors.As(err, &apiErr) {
    fmt.Println(apiErr.StatusCode)
    fmt.Println(apiErr.Errors)
}

Helpers:

d1http.IsRateLimited(err)
d1http.IsNotFound(err)
d1http.IsRetryable(err)

Retries are applied to:

  • 429
  • 5xx

Configure:

client := d1http.New(d1http.Config{
    AccountID: "...",
    APIToken: "...",
    Retry: d1http.RetryConfig{
        MaxRetries: 3,
    },
})