Skip to main content

uni_plugin_wasm_rt/
error.rs

1//! Shared error type for the wasm-rt IPC bridge.
2//!
3//! Each loader wraps [`IpcError`] in its own crate-level error enum
4//! via `#[from]` so the trait-surface error variants stay
5//! crate-specific (`ExtismError`, `WasmError`) while the IPC code lives
6//! once. The pool is generic over its own error type — see
7//! [`crate::pool::InstancePool`] — so it doesn't need a shared error.
8
9use thiserror::Error;
10
11/// Errors raised by the Arrow IPC bridge.
12///
13/// Both `uni-plugin-extism` and `uni-plugin-wasm` wrap this in their
14/// crate-level error enums via `#[from]`.
15#[derive(Debug, Error)]
16#[non_exhaustive]
17pub enum IpcError {
18    /// Arrow IPC encode / decode failed at the wasm boundary.
19    #[error("arrow IPC error: {0}")]
20    Arrow(String),
21    /// Called `encode_batches` with no input — there's no schema to
22    /// write into the stream header.
23    #[error("encode_batches: empty input — no schema to write")]
24    EmptyBatchInput,
25    /// FU-2: a plugin attempted to serialize a column tagged with the
26    /// `uni-db.secret-handle` Arrow extension into its output batch.
27    /// The host blocks the serialization so the opaque handle cannot
28    /// leak across the wasm boundary as raw bytes.
29    #[error(
30        "secret leak attempt: column `{column}` is tagged with the `uni-db.secret-handle` Arrow extension and cannot cross the host↔plugin IPC boundary"
31    )]
32    SecretLeakAttempt {
33        /// Name of the offending column.
34        column: String,
35    },
36}