palladium_plugin/
error.rs1use std::fmt;
2
3#[derive(Debug, Clone, PartialEq)]
5pub enum PluginError {
6 AbiMismatch { expected: u32, found: u32 },
8 LoadFailed(String),
10 InitFailed,
12 UnknownType(String),
14 NamespaceViolation,
16 WasmError(String),
18}
19
20impl fmt::Display for PluginError {
21 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
22 match self {
23 Self::AbiMismatch { expected, found } => write!(
24 f,
25 "ABI mismatch: engine expects version {expected}, plugin reports {found}"
26 ),
27 Self::LoadFailed(msg) => write!(f, "plugin load failed: {msg}"),
28 Self::InitFailed => write!(f, "pd_plugin_init returned null or failed"),
29 Self::UnknownType(name) => write!(f, "unknown plugin or actor type: '{name}'"),
30 Self::NamespaceViolation => {
31 write!(
32 f,
33 "plugin requested a namespace not permitted by its manifest"
34 )
35 }
36 Self::WasmError(msg) => write!(f, "WASM error: {msg}"),
37 }
38 }
39}
40
41impl std::error::Error for PluginError {}