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
fix(errors): Entry not found error as 4xx instead of 5xx (#7712)
Jaganb25f071a607d
diff --git a/crates/storage_impl/src/errors.rs b/crates/storage_impl/src/errors.rsindex 2fc7b4fd51..399755c7ab 100644--- a/crates/storage_impl/src/errors.rs+++ b/crates/storage_impl/src/errors.rs@@ -41,7 +41,12 @@ pub enum StorageError {impl From<error_stack::Report<RedisError>> for StorageError {fn from(err: error_stack::Report<RedisError>) -> Self {- Self::RedisError(err)+ match err.current_context() {+ RedisError::NotFound => Self::ValueNotFound("redis value not found".to_string()),+ RedisError::JsonSerializationFailed => Self::SerializationFailed,+ RedisError::JsonDeserializationFailed => Self::DeserializationFailed,+ _ => Self::RedisError(err),+ }}}@@ -53,7 +58,15 @@ impl From<diesel::result::Error> for StorageError {impl From<error_stack::Report<DatabaseError>> for StorageError {fn from(err: error_stack::Report<DatabaseError>) -> Self {- Self::DatabaseError(err)+ match err.current_context() {+ DatabaseError::DatabaseConnectionError => Self::DatabaseConnectionError,+ DatabaseError::NotFound => Self::ValueNotFound(String::from("db value not found")),+ DatabaseError::UniqueViolation => Self::DuplicateValue {+ entity: "db entity",+ key: None,+ },+ _ => Self::DatabaseError(err),+ }}}@@ -72,6 +85,7 @@ impl StorageError {Self::DatabaseError(err) => {matches!(err.current_context(), DatabaseError::UniqueViolation,)}+ Self::DuplicateValue { .. } => true,_ => false,}}