# lore:python-async/retry-selective-exceptions/0007

**Summary:** Catching generic Exception in async retry loops swallows non-retryable/fatal errors, causing wasted retries, latency spikes, and silent failures; restrict retry catches strictly to allowlisted exception types (e.g., `except retryable as e:` or explicitly re-raise).
**Semver:** 1.0.0 | **Kind:** `gotcha` | **Status:** `draft`

## Verbatim Symptoms

- `Fatal errors (e.g., auth failure, bad request, validation error) are retried repeatedly instead of failing fast`
- `Non-retryable exceptions take multiple retry delays before propagating`
- `Side-effects repeated on permanent failure conditions`

## Problem Statement
A common mistake when writing retry loops is using `except Exception as e:` which catches every exception indiscriminately. Permanent/fatal errors (like ValueError, TypeError, AuthenticationError) should never be retried, as retrying them wastes resources, causes unnecessary delay, and may repeat non-idempotent side effects.

## Correct Procedure
1. Pass a tuple of allowed retryable exception classes (e.g., `retryable=(TransientNetworkError, TimeoutError)`) to the retry helper.
2. Use `except retryable as e:` in the retry block so non-matching exceptions bypass the catch and propagate immediately.
3. If using a dynamic exception tuple, ensure it is passed as a tuple to `except` or checked with `isinstance(e, retryable)` and re-raised immediately if False.

## Anti-Patterns
- Using `except Exception:` inside retry loops without re-raising non-retryable errors.
- Assuming all async exceptions are transient network glitches.
- Catching BaseException, which intercepts CancelledError and KeyboardInterrupt.

## Documented Dead Ends
- **Approach:** Catching Exception and sleeping before checking status
  - *Why it fails:* Delays propagation of fatal errors and causes redundant executions.
  - *Time wasted:* ~25 mins

## Executable Verification Evals
- **Docker Image:** `python:3.12-slim`
- **Setup Network:** `none` | **Eval Network:** `none`
- **Fix Command:** `python test_fix.py`
- **Broken Command:** `python test_broken.py`
