use std::fmt;
use std::fmt::Display;
use crate::Key;
#[derive(Debug)]
pub enum Error {
OpenDisplay,
Unexpected,
UnsupportedKey(Key),
UnsupportedChar(char),
}
impl Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
Self::OpenDisplay => f.write_str("failed to open a connection with the X server"),
Self::Unexpected => f.write_str("the X server behaved in an unexpected way"),
Self::UnsupportedKey(k) => write!(f, "the X server does not support the '{k:?}' key"),
Self::UnsupportedChar(c) => write!(f, "the X server does not support the {c:?} char"),
}
}
}
impl std::error::Error for Error {}