Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions crates/router/src/connector/paypal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,26 +174,34 @@ impl ConnectorCommon for Paypal {
.map(|error_details| {
error_details
.iter()
.try_fold::<_, _, CustomResult<_, errors::ConnectorError>>(
String::new(),
|mut acc, error| {
write!(acc, "description - {} ;", error.description)
.try_fold(String::new(), |mut acc, error| {
if let Some(description) = &error.description {
write!(acc, "description - {} ;", description)
.into_report()
.change_context(
errors::ConnectorError::ResponseDeserializationFailed,
)
.attach_printable("Failed to concatenate error details")
.map(|_| acc)
},
)
} else {
Ok(acc)
}
})
})
.transpose()?;
let reason = match error_reason {
Some(err_reason) => err_reason
.is_empty()
.then(|| response.message.to_owned())
.or(Some(err_reason)),
None => Some(response.message.to_owned()),
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let reason = match error_reason {
Some(err_reason) => err_reason
.is_empty()
.then(|| response.message.to_owned())
.or(Some(err_reason)),
None => Some(response.message.to_owned()),
};
let reason = error_reason
.unwrap_or(response.message.to_owned())
.is_empty()
.then_some(response.message.to_owned());


Ok(ErrorResponse {
status_code: res.status_code,
code: response.name,
message: response.message.clone(),
reason: error_reason.or(Some(response.message)),
reason,
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/router/src/connector/paypal/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1380,7 +1380,7 @@ pub struct PaypalOrderErrorResponse {
#[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct ErrorDetails {
pub issue: String,
pub description: String,
pub description: Option<String>,
}

#[derive(Default, Debug, Serialize, Deserialize, PartialEq)]
Expand Down