Skip to content

fidius-core::error Rust

Error types for the Fidius plugin framework.

Structs

fidius-core::error::PluginError

pub

Derives: Debug, Clone, Serialize, Deserialize, PartialEq

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

Name Type Description
code String Machine-readable error code (e.g., "INVALID_INPUT", "NOT_FOUND").
message String Human-readable error message.
details Option < String > Optional structured details as a JSON string.

Methods

new pub
fn new (code : impl Into < String > , message : impl Into < String >) -> Self

Create a new PluginError without details.

Source
    pub fn new(code: impl Into<String>, message: impl Into<String>) -> Self {
        Self {
            code: code.into(),
            message: message.into(),
            details: None,
        }
    }
with_details pub
fn with_details (code : impl Into < String > , message : impl Into < String > , details : serde_json :: Value ,) -> Self

Create a new PluginError with structured details.

The serde_json::Value is serialized to a JSON string for storage.

Source
    pub fn with_details(
        code: impl Into<String>,
        message: impl Into<String>,
        details: serde_json::Value,
    ) -> Self {
        Self {
            code: code.into(),
            message: message.into(),
            details: Some(details.to_string()),
        }
    }
details_value pub
fn details_value (& self) -> Option < serde_json :: Value >

Parse the details field back into a serde_json::Value.

Returns None if details is absent or fails to parse.

Source
    pub fn details_value(&self) -> Option<serde_json::Value> {
        self.details
            .as_deref()
            .and_then(|s| serde_json::from_str(s).ok())
    }