use crate::*;
impl std::fmt::Display for EuvError {
fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
EuvError::Io { message, error } => write!(formatter, "{message}: {error}"),
EuvError::IoPath {
message,
path,
error,
} => {
write!(formatter, "{message} '{}': {error}", path.display())
}
EuvError::Utf8 { message, error } => write!(formatter, "{message}: {error}"),
EuvError::Server(message) => write!(formatter, "{message}"),
EuvError::Message(message) => write!(formatter, "{message}"),
EuvError::Watch(error) => write!(formatter, "{error}"),
}
}
}
impl std::error::Error for EuvError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match self {
EuvError::Io { error, .. } => Some(error),
EuvError::IoPath { error, .. } => Some(error),
EuvError::Utf8 { error, .. } => Some(error),
EuvError::Watch(error) => Some(error),
EuvError::Server(_) | EuvError::Message(_) => None,
}
}
}
impl From<notify::Error> for EuvError {
fn from(error: notify::Error) -> Self {
EuvError::Watch(error)
}
}