From 4d58bdbe2939b9952baf6c8faa48fff09a2409f7 Mon Sep 17 00:00:00 2001 From: Sai Harsha Vardhan <56996463+sai-harsha-vardhan@users.noreply.github.com> Date: Wed, 6 Sep 2023 19:45:33 +0530 Subject: [PATCH] fix(router): send connection_closed errors as 5xx instead of 2xx (#2093) --- crates/router/src/consts.rs | 3 --- crates/router/src/services/api.rs | 12 ------------ 2 files changed, 15 deletions(-) diff --git a/crates/router/src/consts.rs b/crates/router/src/consts.rs index 34d1c0ab8f..d432bfeec8 100644 --- a/crates/router/src/consts.rs +++ b/crates/router/src/consts.rs @@ -13,9 +13,6 @@ pub(crate) const ALPHABETS: [char; 62] = [ pub const REQUEST_TIME_OUT: u64 = 30; pub const REQUEST_TIMEOUT_ERROR_CODE: &str = "TIMEOUT"; pub const REQUEST_TIMEOUT_ERROR_MESSAGE: &str = "Connector did not respond in specified time"; -pub const CONNECTION_CLOSED_ERROR_CODE: &str = "CONNECTION_CLOSED"; -pub const CONNECTION_CLOSED_ERROR_MESSAGE: &str = - "Connection closed before a message could complete"; ///Payment intent fulfillment default timeout (in seconds) pub const DEFAULT_FULFILLMENT_TIME: i64 = 15 * 60; diff --git a/crates/router/src/services/api.rs b/crates/router/src/services/api.rs index f2ff6bb977..2c844958fd 100644 --- a/crates/router/src/services/api.rs +++ b/crates/router/src/services/api.rs @@ -395,18 +395,6 @@ where router_data.response = Err(error_response); router_data.connector_http_status_code = Some(504); Ok(router_data) - } else if error.current_context().is_connection_closed() { - let error_response = ErrorResponse { - code: consts::CONNECTION_CLOSED_ERROR_CODE.to_string(), - message: consts::CONNECTION_CLOSED_ERROR_MESSAGE.to_string(), - reason: Some( - consts::CONNECTION_CLOSED_ERROR_MESSAGE.to_string(), - ), - status_code: 504, - }; - router_data.response = Err(error_response); - router_data.connector_http_status_code = Some(504); - Ok(router_data) } else { Err(error.change_context( errors::ConnectorError::ProcessingStepFailed(None),