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

# Error handling

> Handle Python SDK EvaluatorError types like ConfigurationError, InputValidationError, and RateLimitError, using the retryable attribute to retry.

The SDK provides specific error types to help you handle different scenarios.

```python example.py theme={null}
import time
from learning_commons_evaluators import EvaluatorError, RateLimitError

for attempt in range(3):
  try:
    result = evaluator.evaluate_sync(input)
    break
  except EvaluatorError as e:
    # Every EvaluatorError exposes a boolean retryable attribute
    if not e.retryable or attempt == 2:
      raise
    delay = e.retry_after if isinstance(e, RateLimitError) and e.retry_after else 2 ** attempt # retry_after is in seconds
    time.sleep(delay)
```

## `EvaluatorError`

Evaluators can throw 3 types of `EvaluatorError`s:

| Type | Description |
| - | - |
| `ConfigurationError` | Missing or invalid API keys |
| `InputValidationError` | Invalid input (text too short, invalid grade, etc.) |
| `APIError` | Other API errors ([Subtypes](#apierror)) |

## `APIError`

`APIError`s can be broken down further into more specific error types:

| Type | Description |
| - | - |
| `AuthenticationError` | Invalid API keys |
| `RateLimitError` | Rate limit exceeded; wait and retry |
| `NetworkError` | Network connectivity issues |
| `RequestTimeoutError` | Request timed out |
| `OutputValidationError` | Output failed to parse or didn't match the expected schema |

## Retries

Every `EvaluatorError` exposes a boolean `retryable` attribute:

| Retryable by default | Not retryable by default |
| - | - |
| `RateLimitError` | `ConfigurationError` |
| `NetworkError` | `InputValidationError` |
| `RequestTimeoutError` | `AuthenticationError` |
| `OutputValidationError` | `APIError` with a 4xx status code |
| `APIError` with a 5xx status code | |

<Note>
  To flag a specific instance (e.g., a permanently-bad hostname), `APIError`s and `NetworkError`s also accept `retryable` as an `__init__` kwarg. `APIError`s with status code >= 500 and an unspecified `retryable` attribute will default to `retryable: True`.
</Note>

## Related topics

<CardGroup cols={2}>
  <Card title="Quickstart" icon="rocket" href="/evaluators/getting-started/quickstart#sdk">
    Install the SDK and run your first evaluator.
  </Card>

  <Card title="Configuration" icon="gear" href="/evaluators/sdk-api-reference/python/configuration">
    Configure evaluators, including API keys and options.
  </Card>

  <Card title="Outputs" icon="table" href="/evaluators/sdk-api-reference/python/outputs">
    Understand evaluator output fields and types.
  </Card>
</CardGroup>
