mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-03 13:30:39 +08:00
fix(connector): [Paypal] send valid error_reason in all the error responses (#1914)
This commit is contained in:
committed by
GitHub
parent
38b9c077b7
commit
3df944196f
@ -77,8 +77,8 @@ impl Paypal {
|
||||
.parse_struct("Paypal ErrorResponse")
|
||||
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
|
||||
|
||||
let error_reason = match response.details {
|
||||
Some(order_errors) => order_errors
|
||||
let error_reason = response.details.map(|order_errors| {
|
||||
order_errors
|
||||
.iter()
|
||||
.map(|error| {
|
||||
let mut reason = format!("description - {}", error.description);
|
||||
@ -95,14 +95,13 @@ impl Paypal {
|
||||
reason.push(';');
|
||||
reason
|
||||
})
|
||||
.collect::<String>(),
|
||||
None => consts::NO_ERROR_MESSAGE.to_string(),
|
||||
};
|
||||
.collect::<String>()
|
||||
});
|
||||
Ok(ErrorResponse {
|
||||
status_code: res.status_code,
|
||||
code: response.name,
|
||||
message: response.message,
|
||||
reason: Some(error_reason),
|
||||
message: response.message.clone(),
|
||||
reason: error_reason.or(Some(response.message)),
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -178,18 +177,17 @@ impl ConnectorCommon for Paypal {
|
||||
.parse_struct("Paypal ErrorResponse")
|
||||
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
|
||||
|
||||
let error_reason = match response.details {
|
||||
Some(error_details) => error_details
|
||||
let error_reason = response.details.map(|error_details| {
|
||||
error_details
|
||||
.iter()
|
||||
.map(|error| format!("description - {} ; ", error.description))
|
||||
.collect::<String>(),
|
||||
None => consts::NO_ERROR_MESSAGE.to_string(),
|
||||
};
|
||||
.collect::<String>()
|
||||
});
|
||||
Ok(ErrorResponse {
|
||||
status_code: res.status_code,
|
||||
code: response.name,
|
||||
message: response.message,
|
||||
reason: Some(error_reason),
|
||||
message: response.message.clone(),
|
||||
reason: error_reason.or(Some(response.message)),
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -306,8 +304,8 @@ impl ConnectorIntegration<api::AccessTokenAuth, types::AccessTokenRequestData, t
|
||||
Ok(ErrorResponse {
|
||||
status_code: res.status_code,
|
||||
code: response.error,
|
||||
message: response.error_description,
|
||||
reason: None,
|
||||
message: response.error_description.clone(),
|
||||
reason: Some(response.error_description),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user