vanikam/src/inventory/application/services/errors.rs
Aravinth Manivannan 69dfb926f2
Some checks failed
ci/woodpecker/pr/woodpecker Pipeline failed
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/pull_request_closed/woodpecker Pipeline was successful
fix: check for duplicate store names in owner scope before creating store
2024-07-14 18:29:48 +05:30

32 lines
1 KiB
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,
DuplicateStoreName,
InternalError,
}
impl From<InventoryDBError> for InventoryError {
fn from(value: InventoryDBError) -> Self {
match value {
InventoryDBError::DuplicateCategoryName => Self::DuplicateCategoryName,
InventoryDBError::DuplicateStoreName => Self::DuplicateStoreName,
InventoryDBError::DuplicateStoreID => {
error!("DuplicateStoreID");
Self::InternalError
}
InventoryDBError::InternalError => Self::InternalError,
}
}
}