Skip to main content

talon_core/llm/
error.rs

1//! Error type for OpenAI-compatible chat-completion calls.
2
3use thiserror::Error;
4
5/// Errors returned by [`ChatClient`].
6///
7/// [`ChatClient`]: crate::llm::ChatClient
8#[derive(Debug, Error)]
9#[non_exhaustive]
10pub enum ChatError {
11    /// `reqwest::Client` could not be constructed.
12    #[error("chat client build failed: {message}")]
13    Build {
14        /// Redacted error detail.
15        message: String,
16    },
17
18    /// HTTP transport failure or non-2xx status from the sidecar.
19    #[error(
20        "chat HTTP error{}: {message}",
21        .status.map(|s| format!(" ({s})")).unwrap_or_default()
22    )]
23    Http {
24        /// HTTP status code when a response was received, `None` for transport failures.
25        status: Option<u16>,
26        /// Redacted detail (URL or response body snippet).
27        message: String,
28        /// Whether the underlying transport failure was a timeout.
29        timed_out: bool,
30    },
31
32    /// The server returned a response that did not match the expected schema.
33    #[error("chat response was malformed")]
34    MalformedResponse,
35}