feat: check response status in all GeminiClient methods and add Error::is_retryable() (#10) #15
Reference in New Issue
Block a user
Delete Branch "feat/error-status-and-retryable"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #10
Summary
Self::error_for_status(response).await?onGeminiClientto check response status across all client methods:GenerateContentResponseErrorintoError::VertexErroron non-success status.Error::HttpStatus { status, body }for non-JSON error bodies (e.g., 502/503 from proxies or gateways).error_for_statusingenerate_content,stream_generate_content,count_tokens,text_embeddings, andpredict_image.pub fn is_retryable(&self) -> boolongemini_rs::error::Erroraccording to Vertex AI error guidance:VertexError: returns true for HTTP status codes 429, 500, 503 or gRPC statusRESOURCE_EXHAUSTED,INTERNAL,UNKNOWN,UNAVAILABLE.HttpStatus: returns true for status codes 429, 500, 502, 503 (excluding 504DEADLINE_EXCEEDED).HttpClient: returns true forreqwest::Errortimeouts and connection failures (is_timeout()/is_connect()).Testing
src/error.rstesting retryable and non-retryable classifications forVertexError,HttpStatus, and other error variants.src/client_tests.rsverifying thatgenerate_content,count_tokens,text_embeddings, andpredict_imagereturnError::HttpStatuson non-JSON error responses, andgenerate_contentreturnsError::VertexErroron 400 JSON.cargo test(28 passed) andcargo clippypass cleanly.