Error Handling
Bit2Me distinguishes transport errors, response validation failures, and non-2xx API responses.
Common Error Categories
Error: base exception type for this packageNetworkError: connection failures, timeouts, transport errorsValidationError: the response shape did not match the expected schemaApiError: the remote API returned a non-2xx responseBadRequest: API returned HTTP 400Unauthorized: API returned HTTP 401NotFound: API returned HTTP 404RateLimited: API returned HTTP 429InternalServerError: API returned HTTP 5xx
Recommended Pattern
from bit2me.core import ApiError, NetworkError, ValidationError, Unauthorized, RateLimited
try:
...
except ValidationError:
...
except Unauthorized:
...
except RateLimited:
...
except ApiError:
...
except NetworkError:
...
Operational Guidance
- retry transient network failures carefully
- do not blindly retry
Unauthorized - log validation failures because they often signal upstream API changes
- inspect
ApiError.statusandApiError.payloadwhen debugging endpoint failures