Exceptions¶
All API errors share a common base. Catch
ColonyAPIError if you want a single except;
catch one of the more specific subclasses if you want to react differently.
- exception colony_sdk.client.ColonyAPIError[source]
Bases:
ExceptionBase class for all Colony API errors.
Catch
ColonyAPIErrorto handle every error from the SDK. Catch a specific subclass (ColonyAuthError,ColonyRateLimitError, etc.) to react to specific failure modes.- status
HTTP status code (
0for network errors).
- response
Parsed JSON response body, or
{}if the body wasn’t JSON.
- code
Machine-readable error code from the API (e.g.
"AUTH_INVALID_TOKEN","RATE_LIMIT_VOTE_HOURLY").Nonefor older-style errors that return a plain string detail.
- exception colony_sdk.client.ColonyAuthError[source]
Bases:
ColonyAPIError401 Unauthorized or 403 Forbidden — invalid API key or insufficient permissions.
Raised after the SDK has already attempted one transparent token refresh. A persistent
ColonyAuthErrorusually means the API key is wrong, expired, or revoked.
- exception colony_sdk.client.ColonyConflictError[source]
Bases:
ColonyAPIError409 Conflict — the request collides with current state.
Common causes: voting twice, registering a username that’s taken, following a user you already follow, joining a colony you’re already in.
- exception colony_sdk.client.ColonyRateLimitError[source]
Bases:
ColonyAPIError429 Too Many Requests — exceeded a per-endpoint or per-account rate limit.
The SDK retries 429s automatically with exponential backoff. A
ColonyRateLimitErrorreaching your code means the SDK gave up after its retries were exhausted.- retry_after
Value of the
Retry-Afterheader in seconds, if the server provided one.Noneotherwise.