Build resilient applications with comprehensive error handling in the nekuda SDK.
NekudaError
so you can decide how granular you want your error handling to be.
NekudaError
.
HTML Error Detection
NekudaApiError
with extracted information, instead of failing on JSON parsing.Response Validation Errors
NekudaValidationError
is raised, pinpointing the discrepancy.Example: "Response validation failed for CardDetailsResponse: card_expiry_date: Card expiry must be in MM/YY format"
Helpful Card Not Found Messages
CardNotFoundError
provides a more specific message:RateLimitError
(429) and ServerError
(5xx) are automatically retried by the SDK based on the retry configuration. If all retries fail, the final error is raised.NekudaApiError
instances (and its children like InvalidRequestError
, AuthenticationError
) have consistent attributes for structured logging.
NekudaValidationError
or AuthenticationError
NekudaValidationError
: Indicates an issue with the data sent or received, or a mismatch with the API schema. Retrying the same call will likely fail again. This usually points to a bug in your client code or an unexpected API change.AuthenticationError
: Your API key is invalid. Retrying won’t help until the key is fixed.NekudaValidationError
on input (e.g., when creating MandateData
) should be caught and fixed before making an API call. NekudaValidationError
on response indicates an issue with the data returned by the API not matching the SDK’s expectations.{"error": {"code": "invalid_mandate_id", "message": "Mandate ID 'm-123' not found.", "status_code": 404}}
NekudaError
(and its children) can be easily logged. NekudaApiError
instances also provide code
and status_code
.
Attribute | Example (NekudaApiError ) | Description |
---|---|---|
message | ”Card details not found…” | Human-readable explanation |
code | card_not_found | Stable machine token from API (if available) |
status_code | 404 | HTTP status returned by backend (if API error) |
CardNotFoundError
)NekudaConnectionError
, ServerError
)nekuda
SDK handles retries for ServerError
and RateLimitError
automatically. You typically only need custom retry logic for NekudaConnectionError
if you want more control than simple immediate retries, or if you want to retry application-level logic that includes SDK calls.NekudaValidationError
on input)nekuda
SDK:
Testing Different Error Conditions
NEKUDA_API_KEY
.CardNotFoundError
): Try to reveal a card for a user_id
that has no card, or use an invalid mandate_id
format.MandateData
with invalid values (e.g., negative price).api.nekuda.ai
(e.g., via firewall rule or hosts file) before an SDK call.