use crate::contacts_service::storage::database::DbKey;
use diesel::result::Error as DieselError;
use tari_service_framework::reply_channel::TransportChannelError;
use thiserror::Error;
#[derive(Debug, Error, PartialEq)]
#[allow(clippy::large_enum_variant)]
pub enum ContactsServiceError {
#[error("Contact is not found")]
ContactNotFound,
#[error("Received incorrect response from service request")]
UnexpectedApiResponse,
#[error("Contacts service storage error: `{0}`")]
ContactsServiceStorageError(#[from] ContactsServiceStorageError),
#[error("Transport channel error: `{0}`")]
TransportChannelError(#[from] TransportChannelError),
}
#[derive(Debug, Error, PartialEq)]
pub enum ContactsServiceStorageError {
#[error("This write operation is not supported for provided DbKey")]
OperationNotSupported,
#[error("Error converting a type")]
ConversionError,
#[error("Could not find all values specified for batch operation")]
ValuesNotFound,
#[error("Value not found error: `{0}`")]
ValueNotFound(DbKey),
#[error("Unexpected result error: `{0}`")]
UnexpectedResult(String),
#[error("R2d2 error")]
R2d2Error,
#[error("Diesel error: `{0}`")]
DieselError(#[from] DieselError),
#[error("Diesel connection error: `{0}`")]
DieselConnectionError(#[from] diesel::ConnectionError),
#[error("Database migration error: `{0}`")]
DatabaseMigrationError(String),
#[error("Blocking task spawn error: `{0}`")]
BlockingTaskSpawnError(String),
}