use std::fmt;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum PluginError {
IllegalName(String),
Duplicate(String),
UnknownDep(String),
DepCycle(Vec<String>),
UnknownName(String),
HostStarted,
Stopped,
}
impl fmt::Display for PluginError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::IllegalName(n) => write!(f, "illegal plugin name: {n:?}"),
Self::Duplicate(n) => write!(f, "duplicate plugin: {n:?}"),
Self::UnknownDep(n) => write!(f, "unknown dependency: {n:?}"),
Self::DepCycle(c) => write!(f, "dependency cycle: {c:?}"),
Self::UnknownName(n) => write!(f, "unknown plugin: {n:?}"),
Self::HostStarted => write!(f, "host already started"),
Self::Stopped => write!(f, "host closed"),
}
}
}
impl std::error::Error for PluginError {}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum AskError {
Timeout { target: String },
TargetGone { target: String },
InvalidPayload { target: String },
BusStopped,
}
impl fmt::Display for AskError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Timeout { target } => write!(f, "ask timeout: {target}"),
Self::TargetGone { target } => write!(f, "ask target gone: {target}"),
Self::InvalidPayload { target } => write!(f, "ask invalid payload/contract: {target}"),
Self::BusStopped => write!(f, "bus stopped"),
}
}
}
impl std::error::Error for AskError {}