fix(connector): [Trustpay] handle errors fields as optional in TrustpayErrorResponse object (#1514)

This commit is contained in:
Arjun Karthik
2023-06-22 19:09:39 +05:30
committed by GitHub
parent 4a047ce133
commit efe1ed9b77
2 changed files with 11 additions and 3 deletions

View File

@ -112,8 +112,16 @@ impl ConnectorCommon for Trustpay {
Ok(ErrorResponse {
status_code: res.status_code,
code: response.status.to_string(),
message: format!("{:?}", response.errors.first().unwrap_or(&default_error)),
reason: Some(format!("{:?}", response.errors)),
message: format!(
"{:?}",
response
.errors
.as_ref()
.unwrap_or(&vec![])
.first()
.unwrap_or(&default_error)
),
reason: response.errors.map(|errors| format!("{:?}", errors)),
})
}
}

View File

@ -1290,7 +1290,7 @@ pub struct Errors {
pub struct TrustpayErrorResponse {
pub status: i64,
pub description: Option<String>,
pub errors: Vec<Errors>,
pub errors: Option<Vec<Errors>>,
}
#[derive(Deserialize)]