// SPDX-FileCopyrightText: 2024 Aravinth Manivannan // // SPDX-License-Identifier: AGPL-3.0-or-later use derive_more::{Display, Error}; use log::error; use serde::{Deserialize, Serialize}; use crate::inventory::application::port::output::db::errors::InventoryDBError; pub type InventoryResult = Result; #[derive(Debug, Error, Display, Clone, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)] pub enum InventoryError { DuplicateCategoryName, InternalError, } impl From for InventoryError { fn from(value: InventoryDBError) -> Self { match value { InventoryDBError::DuplicateCategoryName => Self::DuplicateCategoryName, InventoryDBError::DuplicateStoreID => { error!("DuplicateStoreID"); Self::InternalError } InventoryDBError::InternalError => Self::InternalError, } } }