# should_retry_exception

> **Function** in `langchain`

📖 [View in docs](https://reference.langchain.com/python/langchain/agents/middleware/_retry/should_retry_exception)

Check if an exception should trigger a retry.

## Signature

```python
should_retry_exception(
    exc: Exception,
    retry_on: RetryOn,
) -> bool
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `exc` | `Exception` | Yes | The exception that occurred. |
| `retry_on` | `RetryOn` | Yes | Either a tuple of exception types to retry on, or a callable that takes an exception and returns `True` if it should be retried. |

## Returns

`bool`

`True` if the exception should be retried, `False` otherwise.

---

[View source on GitHub](https://github.com/langchain-ai/langchain/blob/02991cb4cf2063d51a07268edafb05fe53de1826/libs/langchain_v1/langchain/agents/middleware/_retry.py#L66)