Skip to content

Commit

Permalink
fix(session_token): log error only when it occurs (#1136)
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhicodes-crypto authored May 22, 2023
1 parent 6ba580f commit ebf3de4
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions crates/router/src/core/payments/operations/payment_session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use async_trait::async_trait;
use common_utils::ext_traits::{AsyncExt, ValueExt};
use error_stack::ResultExt;
use router_derive::PaymentOperation;
use router_env::{instrument, tracing};
use router_env::{instrument, logger, tracing};

use super::{BoxedOperation, Domain, GetTracker, Operation, UpdateTracker, ValidateRequest};
use crate::{
Expand All @@ -14,7 +14,6 @@ use crate::{
payments::{self, helpers, operations, PaymentData},
},
db::StorageInterface,
logger,
routes::AppState,
types::{
api::{self, PaymentIdTypeExt},
Expand Down Expand Up @@ -334,9 +333,12 @@ where
.parse_value::<PaymentMethodsEnabled>("payment_methods_enabled")
})
.filter_map(|parsed_payment_method_result| {
let error = parsed_payment_method_result.as_ref().err();
logger::error!(session_token_parsing_error=?error);
parsed_payment_method_result.ok()
parsed_payment_method_result
.map_err(|err| {
logger::error!(session_token_parsing_error=?err);
err
})
.ok()
})
.flat_map(|parsed_payment_methods_enabled| {
parsed_payment_methods_enabled
Expand Down Expand Up @@ -377,22 +379,21 @@ where
for (connector, payment_method_type, business_sub_label) in
connector_and_supporting_payment_method_type
{
let connector_type = get_connector_type_for_session_token(
payment_method_type,
request,
connector.to_owned(),
);
match api::ConnectorData::get_connector_by_name(connectors, &connector, connector_type)
{
Ok(connector_data) => session_connector_data.push(api::SessionConnectorData {
if let Ok(connector_data) = api::ConnectorData::get_connector_by_name(
connectors,
&connector,
api::GetToken::from(payment_method_type),
)
.map_err(|err| {
logger::error!(session_token_error=?err);
err
}) {
session_connector_data.push(api::SessionConnectorData {
payment_method_type,
connector: connector_data,
business_sub_label,
}),
Err(error) => {
logger::error!(session_token_error=?error)
}
}
})
};
}

Ok(api::ConnectorChoice::SessionMultiple(
Expand Down

0 comments on commit ebf3de4

Please sign in to comment.