fix(connector): [Paypal]fix error deserelization for source verification call (#2611)

This commit is contained in:
chikke srujan
2023-10-18 14:04:13 +05:30
committed by GitHub
parent a1472c6b78
commit da77d1393b
2 changed files with 13 additions and 8 deletions

View File

@ -174,26 +174,31 @@ impl ConnectorCommon for Paypal {
.map(|error_details| { .map(|error_details| {
error_details error_details
.iter() .iter()
.try_fold::<_, _, CustomResult<_, errors::ConnectorError>>( .try_fold(String::new(), |mut acc, error| {
String::new(), if let Some(description) = &error.description {
|mut acc, error| { write!(acc, "description - {} ;", description)
write!(acc, "description - {} ;", error.description)
.into_report() .into_report()
.change_context( .change_context(
errors::ConnectorError::ResponseDeserializationFailed, errors::ConnectorError::ResponseDeserializationFailed,
) )
.attach_printable("Failed to concatenate error details") .attach_printable("Failed to concatenate error details")
.map(|_| acc) .map(|_| acc)
}, } else {
) Ok(acc)
}
})
}) })
.transpose()?; .transpose()?;
let reason = error_reason
.unwrap_or(response.message.to_owned())
.is_empty()
.then_some(response.message.to_owned());
Ok(ErrorResponse { Ok(ErrorResponse {
status_code: res.status_code, status_code: res.status_code,
code: response.name, code: response.name,
message: response.message.clone(), message: response.message.clone(),
reason: error_reason.or(Some(response.message)), reason,
}) })
} }
} }

View File

@ -1380,7 +1380,7 @@ pub struct PaypalOrderErrorResponse {
#[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq)] #[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct ErrorDetails { pub struct ErrorDetails {
pub issue: String, pub issue: String,
pub description: String, pub description: Option<String>,
} }
#[derive(Default, Debug, Serialize, Deserialize, PartialEq)] #[derive(Default, Debug, Serialize, Deserialize, PartialEq)]