mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-02 12:06:56 +08:00
refactor(router): fixed unprocessable entity error message to custom message (#1979)
Co-authored-by: Sahkal Poddar <sahkal.poddar@juspay.in>
This commit is contained in:
@ -223,8 +223,8 @@ pub enum StripeErrorCode {
|
||||
WebhookProcessingError,
|
||||
#[error(error_type = StripeErrorType::InvalidRequestError, code = "payment_method_unactivated", message = "The operation cannot be performed as the payment method used has not been activated. Activate the payment method in the Dashboard, then try again.")]
|
||||
PaymentMethodUnactivated,
|
||||
#[error(error_type = StripeErrorType::HyperswitchError, code = "", message = "{entity} expired or invalid")]
|
||||
HyperswitchUnprocessableEntity { entity: String },
|
||||
#[error(error_type = StripeErrorType::HyperswitchError, code = "", message = "{message}")]
|
||||
HyperswitchUnprocessableEntity { message: String },
|
||||
#[error(error_type = StripeErrorType::InvalidRequestError, code = "", message = "{message}")]
|
||||
CurrencyNotSupported { message: String },
|
||||
// [#216]: https://github.com/juspay/hyperswitch/issues/216
|
||||
@ -403,8 +403,8 @@ impl From<errors::ApiErrorResponse> for StripeErrorCode {
|
||||
param: field_name.to_string(),
|
||||
}
|
||||
}
|
||||
errors::ApiErrorResponse::UnprocessableEntity { entity } => {
|
||||
Self::HyperswitchUnprocessableEntity { entity }
|
||||
errors::ApiErrorResponse::UnprocessableEntity { message } => {
|
||||
Self::HyperswitchUnprocessableEntity { message }
|
||||
}
|
||||
errors::ApiErrorResponse::MissingRequiredFields { field_names } => {
|
||||
// Instead of creating a new error variant in StripeErrorCode for MissingRequiredFields, converted vec<&str> to String
|
||||
|
||||
@ -92,8 +92,8 @@ pub enum ApiErrorResponse {
|
||||
AccessForbidden,
|
||||
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_23", message = "{message}")]
|
||||
FileProviderNotSupported { message: String },
|
||||
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_23", message = "{entity} expired or invalid")]
|
||||
UnprocessableEntity { entity: String },
|
||||
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_23", message = "{message}")]
|
||||
UnprocessableEntity { message: String },
|
||||
#[error(error_type = ErrorType::ConnectorError, code = "CE_00", message = "{code}: {message}", ignore = "status_code")]
|
||||
ExternalConnectorError {
|
||||
code: String,
|
||||
|
||||
@ -93,7 +93,7 @@ impl ErrorSwitch<api_models::errors::types::ApiErrorResponse> for ApiErrorRespon
|
||||
Self::FileProviderNotSupported { message } => {
|
||||
AER::BadRequest(ApiError::new("IR", 23, message.to_string(), None))
|
||||
},
|
||||
Self::UnprocessableEntity {entity} => AER::Unprocessable(ApiError::new("IR", 23, format!("{entity} expired or invalid"), None)),
|
||||
Self::UnprocessableEntity {message} => AER::Unprocessable(ApiError::new("IR", 23, message.to_string(), None)),
|
||||
Self::ExternalConnectorError {
|
||||
code,
|
||||
message,
|
||||
|
||||
@ -1085,7 +1085,7 @@ pub async fn get_tokenized_data(
|
||||
metrics::TEMP_LOCKER_FAILURES.add(&metrics::CONTEXT, 1, &[]);
|
||||
match err.status_code {
|
||||
404 => Err(errors::ApiErrorResponse::UnprocessableEntity {
|
||||
entity: "Token".to_string(),
|
||||
message: "Token is invalid or expired".into(),
|
||||
}
|
||||
.into()),
|
||||
_ => Err(errors::ApiErrorResponse::InternalServerError)
|
||||
|
||||
@ -1202,7 +1202,9 @@ pub async fn make_pm_data<'a, F: Clone, R>(
|
||||
.change_context(errors::ApiErrorResponse::InternalServerError)
|
||||
.attach_printable("Failed to fetch the token from redis")?
|
||||
.ok_or(error_stack::Report::new(
|
||||
errors::ApiErrorResponse::UnprocessableEntity { entity: token },
|
||||
errors::ApiErrorResponse::UnprocessableEntity {
|
||||
message: token + " is invalid or expired",
|
||||
},
|
||||
))?;
|
||||
|
||||
Some(key)
|
||||
@ -2424,7 +2426,7 @@ pub async fn get_merchant_connector_account(
|
||||
let decrypted_mca = services::decrypt_jwe(mca_config.config.as_str(), services::KeyIdCheck::SkipKeyIdCheck, private_key, jwe::RSA_OAEP_256)
|
||||
.await
|
||||
.change_context(errors::ApiErrorResponse::UnprocessableEntity{
|
||||
entity: "merchant_connector_details".to_string()})
|
||||
message: "decoding merchant_connector_details failed due to invalid data format!".into()})
|
||||
.attach_printable(
|
||||
"Failed to decrypt merchant_connector_details sent in request and then put in cache",
|
||||
)?;
|
||||
|
||||
Reference in New Issue
Block a user