From 79397b6b44d58fab0e131c8a421b64964c4caa25 Mon Sep 17 00:00:00 2001 From: Aravinth Manivannan Date: Mon, 15 Jul 2024 17:53:33 +0530 Subject: [PATCH] feat: handle duplicate ID and name for Product and CategoryAggregate --- src/inventory/adapters/output/db/postgres/errors.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/inventory/adapters/output/db/postgres/errors.rs b/src/inventory/adapters/output/db/postgres/errors.rs index e4e9378..a3ac3f6 100644 --- a/src/inventory/adapters/output/db/postgres/errors.rs +++ b/src/inventory/adapters/output/db/postgres/errors.rs @@ -17,6 +17,14 @@ impl From for InventoryDBError { let msg = err.message(); if msg.contains("cqrs_inventory_store_query_store_id_key") { return Self::DuplicateStoreID; + } else if msg.contains("cqrs_inventory_store_query_product_id_key") { + return Self::DuplicateProductID; + } else if msg.contains("cqrs_inventory_store_query_category_id_key") { + return Self::DuplicateCategoryID; + } else if msg.contains("cqrs_inventory_product_query_name_key") { + return Self::DuplicateProductName; + } else if msg.contains("cqrs_inventory_category_query_name_key") { + return Self::DuplicateProductName; } else if msg.contains("cqrs_inventory_store_query_name_key") { return Self::DuplicateStoreName; } else {