Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
fix(connector): [Gigadat] handle non-JSON error responses (#15238)
nithin-juspay96bbe605757c
diff --git a/crates/hyperswitch_connectors/src/connectors/gigadat.rs b/crates/hyperswitch_connectors/src/connectors/gigadat.rsindex 3056d20f07..256842d21a 100644--- a/crates/hyperswitch_connectors/src/connectors/gigadat.rs+++ b/crates/hyperswitch_connectors/src/connectors/gigadat.rs@@ -166,27 +166,41 @@ impl ConnectorCommon for Gigadat {res: Response,event_builder: Option<&mut ConnectorEvent>,) -> CustomResult<ErrorResponse, errors::ConnectorError> {- let response: gigadat::GigadatErrorResponse = res- .response- .parse_struct("GigadatErrorResponse")- .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;-- event_builder.map(|i| i.set_response_body(&response));- router_env::logger::info!(connector_response=?response);-- Ok(ErrorResponse {- status_code: res.status_code,- code: response.err.clone(),- message: response.err.clone(),- reason: Some(response.err).clone(),- attempt_status: None,- connector_transaction_id: None,- connector_response_reference_id: None,- network_advice_code: None,- network_decline_code: None,- network_error_message: None,- connector_metadata: None,- })+ let response: Result<+ gigadat::GigadatErrorResponse,+ error_stack::Report<common_utils::errors::ParsingError>,+ > = res.response.parse_struct("GigadatErrorResponse");++ match response {+ Ok(response) => {+ event_builder.map(|i| i.set_response_body(&response));+ router_env::logger::info!(connector_response=?response);++ Ok(ErrorResponse {+ status_code: res.status_code,+ code: response.err.clone(),+ message: response.err.clone(),+ reason: Some(response.err).clone(),+ attempt_status: None,+ connector_transaction_id: None,+ connector_response_reference_id: None,+ network_advice_code: None,+ network_decline_code: None,+ network_error_message: None,+ connector_metadata: None,+ })+ }+ Err(error_message) => {+ event_builder.map(|event| {+ event.set_error(serde_json::json!({+ "error": res.response.escape_ascii().to_string(),+ "status_code": res.status_code,+ }))+ });+ router_env::logger::error!(deserialization_error =? error_message);+ utils::handle_json_response_deserialization_failure(res, "gigadat")+ }+ }}}