gemini_chat_api/error.rs
1//! Error types for this crate.
2
3use thiserror::Error;
4
5/// Main error type for Gemini client operations.
6#[derive(Error, Debug)]
7pub enum Error {
8 /// Authentication failed (invalid or expired cookies, or login redirect).
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 a response from the web endpoint.
17 #[error("Parse error: {0}")]
18 Parse(String),
19
20 /// Request timed out.
21 ///
22 /// Note: the current implementation uses `reqwest` timeouts, which are
23 /// reported as `Error::Network` rather than this variant.
24 #[error("Request timed out")]
25 Timeout,
26
27 /// Cookie file not found or invalid.
28 #[error("Cookie error: {0}")]
29 Cookie(String),
30
31 /// File I/O error.
32 #[error("I/O error: {0}")]
33 Io(#[from] std::io::Error),
34
35 /// JSON serialization/deserialization error.
36 #[error("JSON error: {0}")]
37 Json(#[from] serde_json::Error),
38
39 /// Client not initialized properly.
40 #[error("Client not initialized: {0}")]
41 NotInitialized(String),
42
43 /// File upload failed.
44 #[error("Upload failed: {0}")]
45 Upload(String),
46}
47
48/// Result type alias for this crate.
49pub type Result<T> = std::result::Result<T, Error>;