Skip to main content

Handling errors

When using the TBPlusSDK, all API requests are wrapped with internal error handling logic. If the API returns an error, a custom exception TatrapayPlusApiException is raised. This allows you to catch and respond to failures in a structured way.

Basic usage

Wrap all client calls in a try/except block to catch and handle TatrapayPlusApiException.

from tatrapayplus.errors import TatrapayPlusApiException

try:
payment_response = client.create_payment(
request=payment_data,
redirect_uri="https://tatrabanka.sk/",
ip_address="127.0.0.1"
)
except TatrapayPlusApiException as e:
print("Payment failed:", e)
# Handle error

Error body types

When a TatrapayPlusApiException is raised, the error_body attribute will contain one of three structured model instances, depending on which endpoint was called and what kind of error occurred.

Supported models

ModelDescriptionWhen it's used
GetAccessTokenResponse400Returned from the auth endpoint when authentication fails.Invalid client credentials
Field400ErrorBodyReturned when a 400 Bad Request is caused by invalid input or unsupported operation.Validation/business rule errors
Field40XErrorBodyReturned for other 40X errors like 403, 404, etc.Authorization or access issues