Skip to main content

gemini_chat_api/
error.rs

1//! Error types for the Gemini Chat API client.
2
3use thiserror::Error;
4
5/// Main error type for the Gemini client.
6#[derive(Error, Debug)]
7pub enum Error {
8    /// Authentication failed - cookies are invalid or expired.
9    #[error("Authentication failed: {0}")]
10    Authentication(String),
11
12    /// Network request failed.
13    #[error("Network error: {0}")]
14    Network(#[from] reqwest::Error),
15
16    /// Failed to parse response from Gemini.
17    #[error("Parse error: {0}")]
18    Parse(String),
19
20    /// Request timed out.
21    #[error("Request timed out")]
22    Timeout,
23
24    /// Cookie file not found or invalid.
25    #[error("Cookie error: {0}")]
26    Cookie(String),
27
28    /// File I/O error.
29    #[error("I/O error: {0}")]
30    Io(#[from] std::io::Error),
31
32    /// JSON serialization/deserialization error.
33    #[error("JSON error: {0}")]
34    Json(#[from] serde_json::Error),
35
36    /// Client not initialized properly.
37    #[error("Client not initialized: {0}")]
38    NotInitialized(String),
39
40    /// File upload failed.
41    #[error("Upload failed: {0}")]
42    Upload(String),
43}
44
45/// Result type alias for Gemini operations.
46pub type Result<T> = std::result::Result<T, Error>;