use std::fmt;

#[derive(Debug)]
pub enum CclockError {
    WindowTooSmall(usize, usize),
    UnknownArgument(String),
    UnknownFont,
    UnknownColor,
}

impl fmt::Display for CclockError {
    fn fmt(&self, f: &mut fmt::Formatter <'_>) -> fmt::Result {
        let printable = match self {
            Self::WindowTooSmall(w, h) => format!("window too small: {w}x{h}"),
            Self::UnknownArgument(s) => s.to_string(),
            Self::UnknownFont => "unknown font".to_string(),
            Self::UnknownColor => "unknown color".to_string(),
        };
        write!(f, "{}", printable)
    }
}

impl std::error::Error for CclockError {}

impl From<pico_args::Error> for CclockError {
    fn from(err: pico_args::Error) -> Self {
        CclockError::UnknownArgument(err.to_string())
    }
}
