Error Handling
Typed Clients should distinguish between failure modes clearly.
Common Error Categories
NetworkError: connection failures, timeouts, transport errorsAuthError: missing credentials, invalid signatures, rejected authenticationApiError: the remote API returned an application-level errorValidationError: the response shape did not match the expected schemaBadRequest: invalid request or rejected client inputRateLimited: Alchemy rate-limit responseLogicError: local SDK logic error
Recommended Pattern
from alchemy import ApiError, AuthError, NetworkError, RateLimited, ValidationError
try:
...
except ValidationError:
...
except RateLimited:
...
except AuthError:
...
except ApiError:
...
except NetworkError:
...
Operational Guidance
- retry transient network failures carefully
- do not blindly retry authentication failures
- log validation failures because they often signal upstream API changes
- include request identifiers from the exchange when available