Lotus.AI.Error (Lotus v0.16.5)

Copy Markdown View Source

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.

Summary

Functions

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

Functions

wrap(arg1)

@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{}