Skip to main content

vtcode_llm/providers/gemini/wire/streaming/
errors.rs

1use std::time::Duration;
2
3/// Streaming error types for better error classification and handling
4#[derive(Debug, Clone, thiserror::Error)]
5pub enum StreamingError {
6    /// Network-related errors (connection, timeout, DNS, etc.)
7    #[error("Network error: {message}")]
8    NetworkError { message: String, is_retryable: bool },
9    /// API-related errors (rate limits, authentication, etc.)
10    #[error("API error ({status_code}): {message}")]
11    ApiError {
12        status_code: u16,
13        message: String,
14        is_retryable: bool,
15    },
16    /// Response parsing errors
17    #[error("Parse error: {message}")]
18    ParseError { message: String, raw_response: String },
19    /// Timeout errors
20    #[error("Timeout during {operation} after {duration:?}")]
21    TimeoutError { operation: String, duration: Duration },
22    /// Content validation errors
23    #[error("Content error: {message}")]
24    ContentError { message: String },
25    /// Streaming-specific errors
26    #[error("Streaming error: {message}")]
27    StreamingError {
28        message: String,
29        partial_content: Option<String>,
30    },
31}