vanikam/src/inventory/application/services/errors.rs
Aravinth Manivannan 19b6c5420b
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
ci/woodpecker/pr/woodpecker Pipeline failed
feat: define store aggregates and implement service to create store
2024-07-13 17:40:11 +05:30

30 lines
962 B
Rust

// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
//
// 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<V> = Result<V, InventoryError>;
#[derive(Debug, Error, Display, Clone, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
pub enum InventoryError {
DuplicateCategoryName,
InternalError,
}
impl From<InventoryDBError> for InventoryError {
fn from(value: InventoryDBError) -> Self {
match value {
InventoryDBError::DuplicateCategoryName => Self::DuplicateCategoryName,
InventoryDBError::DuplicateStoreID => {
error!("DuplicateStoreID");
Self::InternalError
}
InventoryDBError::InternalError => Self::InternalError,
}
}
}