mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-04 05:59:48 +08:00
refactor(router): return generic message for UnprocessableEntity in make_pm_data (#2050)
This commit is contained in:
@ -1860,11 +1860,7 @@ pub async fn list_customer_payment_method(
|
||||
consts::TOKEN_TTL - time_elapsed.whole_seconds(),
|
||||
)
|
||||
.await
|
||||
.map_err(|error| {
|
||||
logger::error!(connector_payment_method_token_kv_error=?error);
|
||||
errors::StorageError::KVError
|
||||
})
|
||||
.into_report()
|
||||
.change_context(errors::StorageError::KVError)
|
||||
.change_context(errors::ApiErrorResponse::InternalServerError)
|
||||
.attach_printable("Failed to add data in redis")?;
|
||||
}
|
||||
|
||||
@ -1203,7 +1203,7 @@ pub async fn make_pm_data<'a, F: Clone, R>(
|
||||
.attach_printable("Failed to fetch the token from redis")?
|
||||
.ok_or(error_stack::Report::new(
|
||||
errors::ApiErrorResponse::UnprocessableEntity {
|
||||
message: token + " is invalid or expired",
|
||||
message: "Token is invalid or expired".to_owned(),
|
||||
},
|
||||
))?;
|
||||
|
||||
|
||||
@ -11,7 +11,6 @@ use super::{MockDb, Store};
|
||||
use crate::{
|
||||
connection,
|
||||
core::errors::{self, CustomResult},
|
||||
services::logger,
|
||||
types::{
|
||||
self,
|
||||
domain::{
|
||||
@ -80,11 +79,7 @@ impl ConnectorAccessToken for Store {
|
||||
.map_err(Into::<errors::StorageError>::into)?
|
||||
.set_key_with_expiry(&key, serialized_access_token, access_token.expires)
|
||||
.await
|
||||
.map_err(|error| {
|
||||
logger::error!(access_token_kv_error=?error);
|
||||
errors::StorageError::KVError
|
||||
})
|
||||
.into_report()
|
||||
.change_context(errors::StorageError::KVError)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
use actix_web::{web, HttpRequest, HttpResponse};
|
||||
use common_utils::{consts::TOKEN_TTL, errors::CustomResult};
|
||||
use error_stack::{IntoReport, ResultExt};
|
||||
use error_stack::ResultExt;
|
||||
use router_env::{instrument, logger, tracing, Flow};
|
||||
use time::PrimitiveDateTime;
|
||||
|
||||
@ -397,13 +397,9 @@ impl ParentPaymentMethodToken {
|
||||
TOKEN_TTL - time_elapsed.whole_seconds(),
|
||||
)
|
||||
.await
|
||||
.map_err(|error| {
|
||||
logger::error!(hyperswitch_token_kv_error=?error);
|
||||
errors::StorageError::KVError
|
||||
})
|
||||
.into_report()
|
||||
.change_context(errors::StorageError::KVError)
|
||||
.change_context(errors::ApiErrorResponse::InternalServerError)
|
||||
.attach_printable("Failed to add data in redis")?;
|
||||
.attach_printable("Failed to add token in redis")?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user