Skip to main content

Errors and Retries

All SDK errors inherit from DalyAPIError.

Exception Mapping

HTTP conditionException
401AuthenticationError
403ForbiddenError
404NotFoundError
409ConflictError
400 / 422ValidationError
429RateLimitError
5xxServerError
request timeoutTimeoutError
other non-2xxDalyAPIError

Retry Semantics

  • The SDK does not do general automatic retries.
  • It retries once only for 401 after token invalidation/refresh.
  • Caller-managed retries are recommended for 429, transient 5xx, and timeouts.

Rate-Limit Support

RateLimitError includes retry_after when API returns Retry-After header.

Timeout Semantics

SDK wraps httpx timeout exceptions into TimeoutError with:
  • status_code = 0
  • consistent DalyAPIError inheritance for unified exception handling

Suggested Catch Pattern

from dalysdk import DalyAPIError, ValidationError, RateLimitError

try:
    result = client.energy_models.create(payload, timeout=120)
except ValidationError as exc:
    print("Input issue:", exc.detail)
except RateLimitError as exc:
    print("Rate limited; retry after:", exc.retry_after)
except DalyAPIError as exc:
    print(f"API error [{exc.status_code}] {exc.detail}")