from kaleido_sdk import (
KaleidoError,
APIError,
NetworkError,
ValidationError,
TimeoutError,
NotFoundError,
QuoteExpiredError,
NodeNotConfiguredError,
InsufficientBalanceError,
RateLimitError,
PairQuoteRequest,
CreateSwapOrderRequest,
)
import time
try:
quote = await client.maker.get_quote(PairQuoteRequest(...))
order = await client.maker.create_swap_order(CreateSwapOrderRequest(...))
except QuoteExpiredError:
# Get a fresh quote and retry
pass
except InsufficientBalanceError as e:
print(f"Need {e.required_amount}, have {e.available_amount}")
except ValidationError as e:
print(f"Invalid request: {e}")
except RateLimitError as e:
time.sleep(e.retry_after or 5)
except NotFoundError:
print("Resource not found")
except TimeoutError:
print("Request timed out, retrying...")
except NetworkError:
print("Network issue, check connectivity")
except NodeNotConfiguredError:
print("Node not configured")
except APIError as e:
print(f"API error ({e.status_code}): {e}")
except KaleidoError as e:
print(f"SDK error [{e.code}]: {e}")