1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
use thiserror::Error;
macro_rules! log_on_error {
($a: expr) => {
match $a {
Ok(value) => value,
Err(err) => log::error!("{}", LeftError::from(err)),
}
};
}
macro_rules! exit_on_error {
($a: expr) => {
match $a {
Ok(value) => value,
Err(err) => {
log::error!("Exiting due to error: {}", LeftError::from(err));
std::process::exit(1);
}
}
};
}
pub(crate) use exit_on_error;
pub(crate) use log_on_error;
pub type Result<T> = std::result::Result<T, LeftError>;
pub type Error = std::result::Result<(), LeftError>;
#[derive(Debug, Error)]
pub enum LeftError {
#[error("IO error: {0}.")]
IoError(#[from] std::io::Error),
#[error("Nix errno: {0}.")]
NixErrno(#[from] nix::errno::Errno),
#[error("Xlib error: {0}.")]
XlibError(#[from] x11_dl::error::OpenError),
#[error("XDG error: {0}.")]
XdgBaseDirError(#[from] xdg::BaseDirectoriesError),
#[error("No command found for keybind.")]
CommandNotFound,
#[error("No key found for keybind.")]
KeyNotFound,
#[error("No modifier found for keybind.")]
ModifierNotFound,
#[error("No config file found.")]
NoConfigFound,
#[error("No value set for execution.")]
ValueNotFound,
#[error("Config watcher dropped.")]
WatcherDropped,
#[error("X failed status error.")]
XFailedStatus,
}