nautechsystems/nautilus_trader · error · PluginError

PluginErrorCode::Panic

PluginErrorCode::Panic

Error message

PluginError::panic(message)

What it means

PluginError::panic is the plugin-boundary constructor that packages a panic payload (message string) into a PluginError carrying the panic code, so the failure crosses the FFI edge as an error value instead of unwinding across it.

Source

Thrown at crates/plugin/src/boundary.rs:342

    pub fn generic(message: impl AsRef<str>) -> Self {
        Self {
            code: PluginErrorCode::Generic,
            message: OwnedBytes::from_vec(message.as_ref().as_bytes().to_vec()),
        }
    }

    /// Constructs an error with the given code and message string.
    #[must_use]
    pub fn new(code: PluginErrorCode, message: impl AsRef<str>) -> Self {
        Self {
            code,
            message: OwnedBytes::from_vec(message.as_ref().as_bytes().to_vec()),
        }
    }

    /// Constructs a panic error with the given message.
    #[must_use]
    pub fn panic(message: impl AsRef<str>) -> Self {
        Self::new(PluginErrorCode::Panic, message)
    }

    /// Returns the message as a `String` (lossy if non-UTF8).
    #[must_use]
    pub fn message_string(&self) -> String {
        // SAFETY: message is live until self is dropped.
        let bytes = unsafe { self.message.as_bytes() };
        String::from_utf8_lossy(bytes).into_owned()
    }
}

impl core::fmt::Debug for PluginError {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        f.debug_struct(stringify!(PluginError))
            .field("code", &self.code)
            .field("message", &self.message_string())
            .finish()

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Inspect the packaged message for the original panic payload and location
  2. Fix the panicking code path in the plugin and redeploy
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at crates/plugin/src/boundary.rs:342 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08). Data as JSON: /api/errors/b8b8c0cf60a18769. Report an issue: GitHub.