gemini_rust/
error.rs

1use thiserror::Error;
2
3/// Errors that can occur when using the Gemini API
4#[derive(Error, Debug)]
5pub enum Error {
6    /// Error from the reqwest HTTP client
7    #[error("HTTP error: {0}")]
8    HttpError(#[from] reqwest::Error),
9
10    /// Error parsing JSON
11    #[error("JSON error: {0}")]
12    JsonError(#[from] serde_json::Error),
13
14    /// Error from the Gemini API
15    #[error("Gemini API error: {status_code} - {message}")]
16    ApiError {
17        /// HTTP status code
18        status_code: u16,
19        /// Error message
20        message: String,
21    },
22
23    /// Error building a valid request
24    #[error("Request building error: {0}")]
25    RequestError(String),
26
27    /// Missing API key
28    #[error("Missing API key")]
29    MissingApiKey,
30
31    /// Error with function calls
32    #[error("Function call error: {0}")]
33    FunctionCallError(String),
34}