use alloc::string::String;
use core::fmt;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum PluginError {
DuplicateHandler(String),
HandlerNotFound(String),
ProcessingFailed(String),
InvalidConfig(String),
}
impl fmt::Display for PluginError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::DuplicateHandler(name) => {
write!(f, "Handler '{name}' already registered")
}
Self::HandlerNotFound(name) => {
write!(f, "Handler '{name}' not found")
}
Self::ProcessingFailed(msg) => {
write!(f, "Plugin processing failed: {msg}")
}
Self::InvalidConfig(msg) => {
write!(f, "Invalid plugin configuration: {msg}")
}
}
}
}
#[cfg(feature = "std")]
impl std::error::Error for PluginError {}
pub type Result<T> = core::result::Result<T, PluginError>;