# `Lotus.AI.Error`
[🔗](https://github.com/typhoonworks/lotus/blob/v0.16.6/lib/lotus/ai/error.ex#L1)

Domain errors for AI service failures.

Wraps raw provider errors (from ReqLLM) into Lotus-owned exceptions
with user-friendly messages. The raw error is logged server-side;
only the wrapped error is returned to callers.

# `wrap`

```elixir
@spec wrap(term()) :: Exception.t()
```

Wraps a raw LLM provider error into a Lotus AI domain error.

Pattern-matches on known `ReqLLM.Error` types and HTTP status codes
to return the appropriate exception. Unknown errors become `ServiceError`.

## Examples

    iex> raw = %ReqLLM.Error.API.Request{status: 429, reason: "rate limited"}
    iex> %Lotus.AI.Error.RateLimitError{} = Lotus.AI.Error.wrap(raw)

    iex> Lotus.AI.Error.wrap(:something_unexpected)
    %Lotus.AI.Error.ServiceError{}

---

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