# `Imp.Errors`
[🔗](https://github.com/deepfates/imp/blob/v0.18.1/lib/imp/exceptions.ex#L155)

Reads the failure classes callers act on, through the wrappers Imp puts
around an error.

An LM error reaches a caller directly (`{:error, %Imp.LMError{}}`), from
a client that raised (`{:lm_failed, client, exception}`), or inside the
`Imp.Predict.ReActV2.StepError` of a turn that got no model response. These
functions accept any of them, with or without the `{:error, _}` around it.

# `context_window_exceeded?`

```elixir
@spec context_window_exceeded?(term()) :: boolean()
```

Whether the provider refused the request because its input is longer than
the model accepts.

    iex> Imp.Errors.context_window_exceeded?(%Imp.LMError{status: 400, context_window_exceeded: true})
    true

    iex> Imp.Errors.context_window_exceeded?({:error, %Imp.LMError{status: 500}})
    false

# `retryable?`

```elixir
@spec retryable?(term()) :: boolean()
```

Whether sending the same request again may succeed.

    iex> Imp.Errors.retryable?(%Imp.LMError{status: 429, retryable: true})
    true

    iex> Imp.Errors.retryable?({:error, %Imp.LMError{status: 400}})
    false

    iex> Imp.Errors.retryable?(%Imp.AdapterParseError{kind: :malformed})
    false

---

*Consult [api-reference.md](api-reference.md) for complete listing*
