mirror of
https://git.proxmox.com/git/proxmox
synced 2025-08-14 02:58:02 +00:00
notify: introduce Error::Generic
... as leaf error-type for anything for which we do not necessarily want a separate enum variant. Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
This commit is contained in:
parent
3ac6f2d9c0
commit
b2089c37c5
@ -25,13 +25,22 @@ mod config;
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
|
/// There was an error serializing the config
|
||||||
ConfigSerialization(Box<dyn StdError + Send + Sync>),
|
ConfigSerialization(Box<dyn StdError + Send + Sync>),
|
||||||
|
/// There was an error deserializing the config
|
||||||
ConfigDeserialization(Box<dyn StdError + Send + Sync>),
|
ConfigDeserialization(Box<dyn StdError + Send + Sync>),
|
||||||
|
/// An endpoint failed to send a notification
|
||||||
NotifyFailed(String, Box<dyn StdError + Send + Sync>),
|
NotifyFailed(String, Box<dyn StdError + Send + Sync>),
|
||||||
|
/// A target does not exist
|
||||||
TargetDoesNotExist(String),
|
TargetDoesNotExist(String),
|
||||||
|
/// Testing one or more notification targets failed
|
||||||
TargetTestFailed(Vec<Box<dyn StdError + Send + Sync>>),
|
TargetTestFailed(Vec<Box<dyn StdError + Send + Sync>>),
|
||||||
|
/// A filter could not be applied
|
||||||
FilterFailed(String),
|
FilterFailed(String),
|
||||||
|
/// The notification's template string could not be rendered
|
||||||
RenderError(Box<dyn StdError + Send + Sync>),
|
RenderError(Box<dyn StdError + Send + Sync>),
|
||||||
|
/// Generic error for anything else
|
||||||
|
Generic(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Display for Error {
|
impl Display for Error {
|
||||||
@ -60,6 +69,7 @@ impl Display for Error {
|
|||||||
write!(f, "could not apply filter: {message}")
|
write!(f, "could not apply filter: {message}")
|
||||||
}
|
}
|
||||||
Error::RenderError(err) => write!(f, "could not render notification template: {err}"),
|
Error::RenderError(err) => write!(f, "could not render notification template: {err}"),
|
||||||
|
Error::Generic(message) => f.write_str(message),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -74,6 +84,7 @@ impl StdError for Error {
|
|||||||
Error::TargetTestFailed(errs) => Some(&*errs[0]),
|
Error::TargetTestFailed(errs) => Some(&*errs[0]),
|
||||||
Error::FilterFailed(_) => None,
|
Error::FilterFailed(_) => None,
|
||||||
Error::RenderError(err) => Some(&**err),
|
Error::RenderError(err) => Some(&**err),
|
||||||
|
Error::Generic(_) => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user