from keystoneos.exceptions import (
APIError, # Base for all API errors
AuthenticationError, # 401
ForbiddenError, # 403
NotFoundError, # 404
ConflictError, # 409
ValidationError, # 422
RateLimitError, # 429
ServerError, # 5xx
WebhookVerificationError,
)
try:
settlement = await client.settlements.get("non-existent-id")
except NotFoundError:
print("Settlement does not exist")
except ConflictError as e:
print(f"State conflict: {e.message}")
except ValidationError as e:
print(f"Invalid input: {e.detail}")
except RateLimitError as e:
print(f"Rate limited. Retry after: {e.retry_after}s")
except ForbiddenError:
print("Insufficient permissions")
except AuthenticationError:
print("Check your M2M credentials")
except ServerError:
print("KeyStone API issue")
except APIError as e:
print(f"API error {e.status_code}: {e.message}")