32 lines
1 KiB
Rust
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,
|
|
}
|
|
}
|
|
}
|