Errors and retries
Every failure a library raises is one of four errors, and all four share a base type, so one handler can catch them all.
- API error. The API refused the request. It carries the HTTP status, a stable
codeto branch on, and a message in the language you asked for. - OAuth error. The token endpoint refused your credentials or the scopes you asked for.
- Maintenance error. The API is briefly unavailable for maintenance.
- Transport error. No usable answer arrived: the connection failed or timed out, or the response could not be read.
Cancelling a call is not an error. It surfaces as your language’s own cancellation.
What is retried
A 429 or 503 that says how long to wait, in a Retry-After header of 60 seconds or less, is retried after exactly that wait. A call makes at most 3 attempts. You can turn retries off by setting the maximum to 1.
Everything else is raised straight away:
- a 429 or 503 with no
Retry-After; - a wait longer than 60 seconds, which the library will not spend inside your call. The error carries
retry_after, so you can schedule the retry yourself; - a transport error, because the request may already have reached the API;
- any stream that has delivered an event.