unraid_notification/
unraidnotifiererror.rs

1use std::error::Error;
2
3/// Errors, InvalidPath is returned if the path is invalid, IOError is used for if the path could
4/// not be read, or the process could not be spawned.
5#[derive(Debug)]
6pub enum UnraidNotifierError {
7    InvalidPath,
8    IOError(std::io::Error),
9}
10
11impl std::fmt::Display for UnraidNotifierError {
12    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
13        match self {
14            UnraidNotifierError::InvalidPath => write!(f, "Invalid path"),
15            UnraidNotifierError::IOError(e) => write!(f, "IO error: {}", e),
16        }
17    }
18}
19
20impl Error for UnraidNotifierError{
21    fn source(&self) -> Option<&(dyn Error + 'static)> {
22        match self{
23            Self::IOError(err) => Some(err),
24            _ => None
25        }
26    }
27}