Skip to main content

llm_kernel/
error.rs

1use thiserror::Error;
2
3/// Errors that can occur when using llm-kernel.
4#[derive(Debug, Error)]
5pub enum KernelError {
6    /// An LLM API returned an error response.
7    #[error("LLM API error: {0}")]
8    LlmApi(String),
9
10    /// The LLM API rate-limited the request.
11    #[error("LLM rate limited: retry after {0}s")]
12    RateLimited(u64),
13
14    /// An HTTP error occurred (non-200 status with code).
15    #[error("HTTP {status}: {message}")]
16    Http { status: u16, message: String },
17
18    /// A request timed out.
19    #[error("Request timed out after {0}s")]
20    Timeout(u64),
21
22    /// A configuration error (missing field, bad format, etc.).
23    #[error("Config error: {0}")]
24    Config(String),
25
26    /// A store (SQLite) error.
27    #[error("Store error: {0}")]
28    Store(String),
29
30    /// A secrets vault error.
31    #[error("Vault error: {0}")]
32    Vault(String),
33
34    /// An I/O error.
35    #[error("IO error: {0}")]
36    Io(#[from] std::io::Error),
37
38    /// A serialization/deserialization error.
39    #[cfg(feature = "provider")]
40    #[error("Serialization error: {0}")]
41    Serialization(#[from] serde_json::Error),
42}
43
44/// Alias for `Result<T, KernelError>`.
45pub type Result<T> = std::result::Result<T, KernelError>;