use std::fmt::Display;

use thiserror::Error;

#[derive(Debug, Error)]
pub enum RepositoryError {
    #[error("entity not found")]
    NotFound,
    #[error("conflict: {0}")]
    Conflict(String),
    #[error("unexpected data store error: {0}")]
    Unexpected(String),
}

impl RepositoryError {
    pub fn conflict<T: Display>(message: T) -> Self {
        Self::Conflict(message.to_string())
    }

    pub fn unexpected<T: Display>(message: T) -> Self {
        Self::Unexpected(message.to_string())
    }
}
