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
feat(errors): add `GenericDuplicateError` in`ApiErrorResponse` (#1792)
Sai Harsha Vardhan7f947169feac
diff --git a/crates/router/src/compatibility/stripe/errors.rs b/crates/router/src/compatibility/stripe/errors.rsindex feec71a37a..fae1e033cc 100644--- a/crates/router/src/compatibility/stripe/errors.rs+++ b/crates/router/src/compatibility/stripe/errors.rs@@ -91,6 +91,9 @@ pub enum StripeErrorCode {#[error(error_type = StripeErrorType::InvalidRequestError, code = "resource_missing", message = "{message}")]GenericNotFoundError { message: String },+ #[error(error_type = StripeErrorType::InvalidRequestError, code = "duplicate_resource", message = "{message}")]+ GenericDuplicateError { message: String },+#[error(error_type = StripeErrorType::InvalidRequestError, code = "resource_missing", message = "No such merchant account")]MerchantAccountNotFound,@@ -411,6 +414,9 @@ impl From<errors::ApiErrorResponse> for StripeErrorCode {errors::ApiErrorResponse::GenericNotFoundError { message } => {Self::GenericNotFoundError { message }}+ errors::ApiErrorResponse::GenericDuplicateError { message } => {+ Self::GenericDuplicateError { message }+ }// parameter unknown, invalid request error // actually if we type wrong values in address we get this error. Stripe throws parameter unknown. I don't know if stripe is validating email and stufferrors::ApiErrorResponse::InvalidDataFormat {field_name,@@ -607,6 +613,7 @@ impl actix_web::ResponseError for StripeErrorCode {| Self::PaymentIntentMandateInvalid { .. }| Self::PaymentIntentUnexpectedState { .. }| Self::DuplicatePayment { .. }+ | Self::GenericDuplicateError { .. }| Self::IncorrectConnectorNameGiven| Self::ResourceMissing { .. }| Self::FileValidationFaileddiff --git a/crates/router/src/core/errors/api_error_response.rs b/crates/router/src/core/errors/api_error_response.rsindex 450eb52a94..e659d5b215 100644--- a/crates/router/src/core/errors/api_error_response.rs+++ b/crates/router/src/core/errors/api_error_response.rs@@ -207,6 +207,8 @@ pub enum ApiErrorResponse {MissingFileContentType,#[error(error_type = ErrorType::InvalidRequestError, code = "HE_05", message = "{message}")]GenericNotFoundError { message: String },+ #[error(error_type = ErrorType::InvalidRequestError, code = "HE_01", message = "{message}")]+ GenericDuplicateError { message: String },#[error(error_type = ErrorType::InvalidRequestError, code = "WE_01", message = "Failed to authenticate the webhook")]WebhookAuthenticationFailed,#[error(error_type = ErrorType::ObjectNotFound, code = "WE_04", message = "Webhook resource not found")]diff --git a/crates/router/src/core/errors/transformers.rs b/crates/router/src/core/errors/transformers.rsindex a315240b0d..2d6774a3d0 100644--- a/crates/router/src/core/errors/transformers.rs+++ b/crates/router/src/core/errors/transformers.rs@@ -135,6 +135,9 @@ impl ErrorSwitch<api_models::errors::types::ApiErrorResponse> for ApiErrorResponSelf::DuplicatePayout { payout_id } => {AER::BadRequest(ApiError::new("HE", 1, format!("The payout with the specified payout_id '{payout_id}' already exists in our records"), None))}+ Self::GenericDuplicateError { message } => {+ AER::BadRequest(ApiError::new("HE", 1, message, None))+ }Self::RefundNotFound => {AER::NotFound(ApiError::new("HE", 2, "Refund does not exist in our records.", None))}