feat: error types for customization table constraint violoations
This commit is contained in:
parent
5937d7a0fd
commit
66464b33f1
3 changed files with 12 additions and 0 deletions
|
@ -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}");
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,5 +15,7 @@ pub enum InventoryDBError {
|
||||||
DuplicateStoreID,
|
DuplicateStoreID,
|
||||||
DuplicateProductName,
|
DuplicateProductName,
|
||||||
DuplicateProductID,
|
DuplicateProductID,
|
||||||
|
DuplicateCustomizationID,
|
||||||
|
DuplicateCustomizationName,
|
||||||
InternalError,
|
InternalError,
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue