lib_client_ollama/
error.rs

1//! Error types for the Ollama client.
2
3use thiserror::Error;
4
5/// Ollama API error type.
6#[derive(Debug, Error)]
7pub enum OllamaError {
8    /// HTTP request failed.
9    #[error("Request failed: {0}")]
10    Request(#[from] reqwest::Error),
11
12    /// API returned an error response.
13    #[error("API error ({status}): {message}")]
14    Api { status: u16, message: String },
15
16    /// Model not found.
17    #[error("Model not found: {0}")]
18    ModelNotFound(String),
19
20    /// Connection refused (Ollama not running).
21    #[error("Connection refused: is Ollama running?")]
22    ConnectionRefused,
23
24    /// JSON serialization/deserialization error.
25    #[error("JSON error: {0}")]
26    Json(#[from] serde_json::Error),
27
28    /// Invalid request parameters.
29    #[error("Invalid request: {0}")]
30    InvalidRequest(String),
31}
32
33/// Result type alias for Ollama operations.
34pub type Result<T> = std::result::Result<T, OllamaError>;