pub struct PluginError {
pub code: String,
pub message: String,
pub details: Option<String>,
}Expand description
Error returned by plugin method implementations to signal business logic failures.
Serialized as bincode across the FFI boundary. The host deserializes
this from the output buffer when the FFI shim returns STATUS_PLUGIN_ERROR.
The details field is stored as a JSON string (not serde_json::Value)
because bincode cannot deserialize a free-form serde_json::Value
(it lacks deserialize_any). Storing it as a String keeps the error
struct bincode-compatible.
Fields§
§code: StringMachine-readable error code (e.g., "INVALID_INPUT", "NOT_FOUND").
message: StringHuman-readable error message.
details: Option<String>Optional structured details as a JSON string.
Implementations§
Source§impl PluginError
impl PluginError
Sourcepub fn new(code: impl Into<String>, message: impl Into<String>) -> PluginError
pub fn new(code: impl Into<String>, message: impl Into<String>) -> PluginError
Create a new PluginError without details.
Sourcepub fn with_details(
code: impl Into<String>,
message: impl Into<String>,
details: Value,
) -> PluginError
pub fn with_details( code: impl Into<String>, message: impl Into<String>, details: Value, ) -> PluginError
Create a new PluginError with structured details.
The serde_json::Value is serialized to a JSON string for storage.
Sourcepub fn details_value(&self) -> Option<Value>
pub fn details_value(&self) -> Option<Value>
Parse the details field back into a serde_json::Value.
Returns None if details is absent or fails to parse.
Trait Implementations§
Source§impl Clone for PluginError
impl Clone for PluginError
Source§fn clone(&self) -> PluginError
fn clone(&self) -> PluginError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PluginError
impl Debug for PluginError
Source§impl<'de> Deserialize<'de> for PluginError
impl<'de> Deserialize<'de> for PluginError
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<PluginError, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<PluginError, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Display for PluginError
impl Display for PluginError
Source§impl Error for PluginError
impl Error for PluginError
1.30.0 · 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()
Source§impl PartialEq for PluginError
impl PartialEq for PluginError
Source§fn eq(&self, other: &PluginError) -> bool
fn eq(&self, other: &PluginError) -> bool
self and other values to be equal, and is used by ==.