Skip to main content

jsdet_core/
error.rs

1/// Errors produced by the jsdet sandbox.
2#[derive(Debug, thiserror::Error)]
3pub enum Error {
4    /// WASM module failed to compile or instantiate.
5    #[error("wasm initialization failed: {0}")]
6    WasmInit(String),
7
8    /// Execution exceeded the configured fuel budget.
9    #[error("execution exceeded fuel budget ({budget} fuel units)")]
10    FuelExhausted { budget: u64 },
11
12    /// Execution exceeded the configured wall-clock timeout.
13    #[error("execution exceeded {timeout_ms}ms timeout")]
14    Timeout { timeout_ms: u64 },
15
16    /// WASM linear memory exceeded the configured limit.
17    #[error("linear memory exceeded {limit_bytes} byte limit")]
18    MemoryExceeded { limit_bytes: usize },
19
20    /// A bridge call returned an error.
21    #[error("bridge error in {api}: {message}")]
22    Bridge { api: String, message: String },
23
24    /// The WASM module trapped (unreachable, divide by zero, etc.).
25    #[error("wasm trap: {0}")]
26    Trap(String),
27
28    /// Internal error — should not happen in normal operation.
29    #[error("internal: {0}")]
30    Internal(String),
31}
32
33pub type Result<T> = std::result::Result<T, Error>;