> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dalyenergy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Errors and Retries

> SDK exception taxonomy, status mapping, and retry semantics

# Errors and Retries

All SDK errors inherit from `DalyAPIError`.

## Exception Mapping

| HTTP condition  | Exception             |
| --------------- | --------------------- |
| `401`           | `AuthenticationError` |
| `403`           | `ForbiddenError`      |
| `404`           | `NotFoundError`       |
| `409`           | `ConflictError`       |
| `400` / `422`   | `ValidationError`     |
| `429`           | `RateLimitError`      |
| `5xx`           | `ServerError`         |
| request timeout | `TimeoutError`        |
| other non-2xx   | `DalyAPIError`        |

## 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

```python theme={null}
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}")
```
