1use alloc::string::String;
7use core::fmt;
8
9#[derive(Debug, Clone, PartialEq, Eq)]
11pub enum PluginError {
12 DuplicateHandler(String),
14 HandlerNotFound(String),
16 ProcessingFailed(String),
18 InvalidConfig(String),
20}
21
22impl fmt::Display for PluginError {
23 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
24 match self {
25 Self::DuplicateHandler(name) => {
26 write!(f, "Handler '{name}' already registered")
27 }
28 Self::HandlerNotFound(name) => {
29 write!(f, "Handler '{name}' not found")
30 }
31 Self::ProcessingFailed(msg) => {
32 write!(f, "Plugin processing failed: {msg}")
33 }
34 Self::InvalidConfig(msg) => {
35 write!(f, "Invalid plugin configuration: {msg}")
36 }
37 }
38 }
39}
40
41#[cfg(feature = "std")]
42impl std::error::Error for PluginError {}
43
44pub type Result<T> = core::result::Result<T, PluginError>;