Skip to main content

uni_plugin_wasm/
error.rs

1//! Error types for the WASM loader.
2
3use thiserror::Error;
4
5/// Errors specific to the WASM loader.
6#[derive(Debug, Error)]
7#[non_exhaustive]
8pub enum WasmError {
9    /// The supplied WASM bytes failed to parse or validate.
10    #[error("wasm parse / validation failure: {0}")]
11    InvalidWasm(String),
12
13    /// Component instantiation failed.
14    #[error("wasm instantiation failed: {0}")]
15    Instantiate(String),
16
17    /// A plugin export call trapped or returned a fn-error.
18    #[error("wasm invoke failed: {0}")]
19    Invoke(String),
20
21    /// Arrow IPC marshalling across the linear-memory boundary failed.
22    #[error("arrow IPC at wasm boundary: {0}")]
23    Ipc(#[from] uni_plugin_wasm_rt::IpcError),
24
25    /// Wall-clock or fuel deadline exceeded.
26    #[error("wasm plugin exceeded resource limit: {0}")]
27    ResourceLimit(String),
28
29    /// Internal / unexpected error.
30    #[error("uni-plugin-wasm internal error: {0}")]
31    Internal(String),
32
33    /// The plugin's declared ABI range does not intersect any
34    /// host-supported major (per the multi-version `Linker` cache in
35    /// [`crate::multi_version`]).
36    #[error("plugin abi {requested} unsupported; host majors: {supported:?}")]
37    AbiUnsupported {
38        /// The plugin's manifest `abi` range string.
39        requested: String,
40        /// Host-supported major versions.
41        supported: Vec<u64>,
42    },
43}
44
45impl uni_plugin_wasm_rt::pool::PoolResourceLimit for WasmError {
46    fn resource_limit(msg: String) -> Self {
47        Self::ResourceLimit(msg)
48    }
49}