use std::fmt;

#[derive(Debug, Clone)]
pub enum Error {
    Msg(String),
    XlsxError(String),
}

impl fmt::Display for Error {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        match self {
            Error::Msg(msg) => write!(f, "{msg}"),
            Error::XlsxError(msg) => write!(f, "XlsxError: {msg}"),
        }
    }
}

impl From<umya_spreadsheet::XlsxError> for Error {
    fn from(value: umya_spreadsheet::XlsxError) -> Self {
        Error::XlsxError(value.to_string())
    }
}

impl From<&str> for Error {
    fn from(value: &str) -> Self {
        Error::Msg(value.to_string())
    }
}

impl From<String> for Error {
    fn from(value: String) -> Self {
        Error::Msg(value)
    }
}
