pub enum PluginError {
Execution {
plugin_name: String,
message: String,
source: Option<Box<dyn Error + Send + Sync>>,
code: Option<String>,
details: HashMap<String, Value>,
proto_error_code: Option<i64>,
},
Timeout {
plugin_name: String,
timeout_ms: u64,
proto_error_code: Option<i64>,
},
Violation {
plugin_name: String,
violation: PluginViolation,
},
Config {
message: String,
},
UnknownHook {
hook_type: String,
},
}Expand description
Top-level error type for the CPEX framework.
Covers plugin execution failures, policy violations, timeouts, and configuration issues. Each variant carries enough context for the caller to log, report, or recover.
Mirrors the Python framework’s PluginErrorModel with:
code— business-logic error code (e.g.,"rate_limit_exceeded")details— structured diagnostic data for loggingproto_error_code— protocol-level error code for the host to map back to the wire format (MCP JSON-RPC, HTTP status, etc.)
Variants§
Execution
A plugin raised an execution error.
Fields
Timeout
A plugin exceeded its execution timeout.
Fields
Violation
A plugin returned a policy violation (deny).
Config
Configuration parsing or validation failed.
UnknownHook
A hook type was not found in the registry.
Implementations§
Source§impl PluginError
impl PluginError
Sourcepub fn boxed(self) -> Box<Self>
pub fn boxed(self) -> Box<Self>
Box this error for use in Result<T, Box<PluginError>>.
Public APIs return Result<T, Box<PluginError>> rather than
Result<T, Box<PluginError>> because the enum is large (~184 bytes
— details: HashMap and the source: Box<dyn Error> push it
well past clippy’s result_large_err threshold). Boxing keeps
Result<T, _> pointer-sized on the success path; the
allocation only happens on the error path.
.boxed() is sugar for Box::new(...) that reads better at
construction sites: PluginError::Config { ... }.boxed().
? already calls From::from, and From<T> for Box<T> is
built into std, so existing ? chains keep working.
Trait Implementations§
Source§impl Debug for PluginError
impl Debug for PluginError
Source§impl Display for PluginError
impl Display for PluginError
Source§impl Error for PluginError
impl Error for PluginError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()