pub enum Error {
Show 14 variants
Api(Box<ApiError>),
Http(Error),
Json(Error),
Io(Error),
Validation(String),
UnsupportedByBackend {
field: &'static str,
backend: Backend,
},
UnsupportedMethod(&'static str),
UnsupportedBackend(&'static str),
FunctionCall(FunctionCallError),
WebSocket(Box<Error>),
Stream(String),
Upload(String),
NoMorePages,
BlockingInsideRuntime,
}Expand description
Top-level error type returned by every fallible gemini_genai call.
Variants§
Api(Box<ApiError>)
A non-2xx response from the Gemini API. Corresponds to Python’s
APIError / ClientError / ServerError. Boxed: ApiError is
large (a String message plus Vec/HashMap detail fields), and
clippy::result_large_err flags an unboxed variant that size on
every one of this crate’s (numerous) Result<T, Error> returns.
Http(Error)
A transport-level failure (connection, TLS, timeout).
Json(Error)
A JSON (de)serialization failure. Corresponds to Python’s
UnknownApiResponseError.
Io(Error)
A local filesystem I/O failure (e.g. reading a file to upload).
Validation(String)
A request failed client-side validation before being sent.
Corresponds to Python’s ValueError.
UnsupportedByBackend
A field was set that only the Vertex AI backend supports; this
client is configured for the Gemini Developer API.
Corresponds to Python’s ValueError('... only supported in ...').
The message reproduces the Python SDK’s
'<field> parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.'.
Fields
UnsupportedMethod(&'static str)
A whole method that only the Vertex AI backend supports was called on
a Gemini Developer API client. Corresponds to Python’s
ValueError('This method is only supported in Gemini Enterprise Agent Platform mode, ...').
UnsupportedBackend(&'static str)
The client was configured to use a backend that is not yet implemented by this crate.
FunctionCall(FunctionCallError)
An automatic-function-calling failure. Corresponds to Python’s
UnknownFunctionCallArgumentError / UnsupportedFunctionError /
FunctionInvocationError.
WebSocket(Box<Error>)
A WebSocket (Live API) transport failure.
Stream(String)
A streamed response (SSE or WebSocket) ended abnormally.
Upload(String)
A resumable file upload failed.
NoMorePages
Pager::next_page was called with no
further pages available. Corresponds to Python’s IndexError.
BlockingInsideRuntime
A blocking client method was called from within an active Tokio runtime, which would deadlock.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()