Remove dead code and fix typo
- Remove unused AUTH_SCOPE constant from client.rs - Remove unused ErrorType, ErrorInfoMetadata, FieldViolation, and Link types from types/error.rs - Fix "EventSourrce" typo in error.rs Display impl
This commit is contained in:
@@ -6,8 +6,6 @@ use tokio_stream::{Stream, StreamExt};
|
|||||||
use tokio_util::codec::LinesCodecError;
|
use tokio_util::codec::LinesCodecError;
|
||||||
use tracing::error;
|
use tracing::error;
|
||||||
|
|
||||||
pub static AUTH_SCOPE: &[&str] = &["https://www.googleapis.com/auth/cloud-platform"];
|
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct GeminiClient {
|
pub struct GeminiClient {
|
||||||
client: reqwest::Client,
|
client: reqwest::Client,
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ impl Display for Error {
|
|||||||
write!(f, "No candidates returned for the prompt")
|
write!(f, "No candidates returned for the prompt")
|
||||||
}
|
}
|
||||||
Error::EventSourceError(e) => {
|
Error::EventSourceError(e) => {
|
||||||
write!(f, "EventSourrce Error: {e}")
|
write!(f, "EventSource Error: {e}")
|
||||||
}
|
}
|
||||||
Error::EventSourceClosedError => {
|
Error::EventSourceClosedError => {
|
||||||
write!(f, "EventSource closed error")
|
write!(f, "EventSource closed error")
|
||||||
|
|||||||
@@ -26,42 +26,12 @@ pub struct GeminiApiError {
|
|||||||
|
|
||||||
impl core::fmt::Display for GeminiApiError {
|
impl core::fmt::Display for GeminiApiError {
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), std::fmt::Error> {
|
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), std::fmt::Error> {
|
||||||
write!(f, "Gemini API Error {} - {}", self.error.code, self.error.message)
|
write!(
|
||||||
|
f,
|
||||||
|
"Gemini API Error {} - {}",
|
||||||
|
self.error.code, self.error.message
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::error::Error for GeminiApiError {}
|
impl std::error::Error for GeminiApiError {}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
|
||||||
pub struct Link {
|
|
||||||
pub description: String,
|
|
||||||
pub url: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
|
||||||
#[serde(tag = "@type")]
|
|
||||||
pub enum ErrorType {
|
|
||||||
#[serde(rename = "type.googleapis.com/google.rpc.ErrorInfo")]
|
|
||||||
ErrorInfo { metadata: ErrorInfoMetadata },
|
|
||||||
|
|
||||||
#[serde(rename = "type.googleapis.com/google.rpc.Help")]
|
|
||||||
Help { links: Vec<Link> },
|
|
||||||
|
|
||||||
#[serde(rename = "type.googleapis.com/google.rpc.BadRequest")]
|
|
||||||
BadRequest {
|
|
||||||
#[serde(rename = "fieldViolations")]
|
|
||||||
field_violations: Vec<FieldViolation>,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
|
||||||
pub struct ErrorInfoMetadata {
|
|
||||||
pub service: String,
|
|
||||||
pub consumer: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
|
||||||
pub struct FieldViolation {
|
|
||||||
pub field: String,
|
|
||||||
pub description: String,
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user