feat: check for Customization constraint violation #43

Merged
realaravinth merged 7 commits from customize-products into master 2024-07-16 11:42:37 +05:30
3 changed files with 12 additions and 0 deletions
Showing only changes of commit 66464b33f1 - Show all commits

View file

@ -19,6 +19,8 @@ impl From<SqlxError> for InventoryDBError {
return Self::DuplicateStoreID; return Self::DuplicateStoreID;
} else if msg.contains("cqrs_inventory_store_query_product_id_key") { } else if msg.contains("cqrs_inventory_store_query_product_id_key") {
return Self::DuplicateProductID; return Self::DuplicateProductID;
} else if msg.contains("cqrs_inventory_product_customizations_query_customization_id_key") {
return Self::DuplicateCustomizationID;
} else if msg.contains("cqrs_inventory_store_query_category_id_key") { } else if msg.contains("cqrs_inventory_store_query_category_id_key") {
return Self::DuplicateCategoryID; return Self::DuplicateCategoryID;
} else if msg.contains("cqrs_inventory_product_query_name_key") { } else if msg.contains("cqrs_inventory_product_query_name_key") {
@ -27,6 +29,8 @@ impl From<SqlxError> for InventoryDBError {
return Self::DuplicateProductName; return Self::DuplicateProductName;
} else if msg.contains("cqrs_inventory_store_query_name_key") { } else if msg.contains("cqrs_inventory_store_query_name_key") {
return Self::DuplicateStoreName; return Self::DuplicateStoreName;
} else if msg.contains("cqrs_inventory_product_customizations_query_name_key") {
return Self::DuplicateCustomizationName
} else { } else {
println!("{msg}"); println!("{msg}");
} }

View file

@ -15,5 +15,7 @@ pub enum InventoryDBError {
DuplicateStoreID, DuplicateStoreID,
DuplicateProductName, DuplicateProductName,
DuplicateProductID, DuplicateProductID,
DuplicateCustomizationID,
DuplicateCustomizationName,
InternalError, InternalError,
} }

View file

@ -15,6 +15,7 @@ pub enum InventoryError {
DuplicateCategoryName, DuplicateCategoryName,
DuplicateStoreName, DuplicateStoreName,
DuplicateProductName, DuplicateProductName,
DuplicateCustomizationName,
InternalError, InternalError,
} }
@ -24,6 +25,7 @@ impl From<InventoryDBError> for InventoryError {
InventoryDBError::DuplicateCategoryName => Self::DuplicateCategoryName, InventoryDBError::DuplicateCategoryName => Self::DuplicateCategoryName,
InventoryDBError::DuplicateStoreName => Self::DuplicateStoreName, InventoryDBError::DuplicateStoreName => Self::DuplicateStoreName,
InventoryDBError::DuplicateProductName => Self::DuplicateProductName, InventoryDBError::DuplicateProductName => Self::DuplicateProductName,
InventoryDBError::DuplicateCustomizationName => Self::DuplicateCustomizationName,
InventoryDBError::DuplicateStoreID => { InventoryDBError::DuplicateStoreID => {
error!("DuplicateStoreID"); error!("DuplicateStoreID");
Self::InternalError Self::InternalError
@ -36,6 +38,10 @@ impl From<InventoryDBError> for InventoryError {
error!("DuplicateCategoryID"); error!("DuplicateCategoryID");
Self::InternalError Self::InternalError
} }
InventoryDBError::DuplicateCustomizationID => {
error!("DuplicateCustomizationID");
Self::InternalError
}
InventoryDBError::InternalError => Self::InternalError, InventoryDBError::InternalError => Self::InternalError,
} }
} }