Improves error handling
This commit is contained in:
24
src/types.rs
24
src/types.rs
@@ -66,8 +66,9 @@ pub struct GenerateContentResponse(pub Vec<ResponseStreamChunk>);
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ResponseStreamChunk {
|
||||
pub candidates: Vec<Candidate>,
|
||||
pub candidates: Option<Vec<Candidate>>,
|
||||
pub usage_metadata: Option<UsageMetadata>,
|
||||
pub error: Option<Error>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
@@ -128,3 +129,24 @@ pub struct FunctionParametersProperty {
|
||||
pub r#type: String,
|
||||
pub description: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct Error {
|
||||
pub code: i32,
|
||||
pub message: String,
|
||||
pub status: String,
|
||||
pub details: Vec<ErrorDetail>,
|
||||
}
|
||||
|
||||
// TODO: Make ErrorDetail an enum and map to the different types of errors.
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct ErrorDetail {
|
||||
#[serde(rename = "@type")]
|
||||
pub r#type: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct Link {
|
||||
pub description: String,
|
||||
pub url: String,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user