Skip to main content

spacedb_query/
error.rs

1//! Errors for compute-to-data.
2
3use thiserror::Error;
4
5pub type QueryResult<T> = Result<T, QueryError>;
6
7#[derive(Debug, Error)]
8pub enum QueryError {
9    /// The wasmtime engine could not be constructed with the runtime's
10    /// deterministic configuration (fuel metering, no backtraces).
11    #[error("engine construction failed: {0}")]
12    Engine(String),
13
14    /// The WASM module failed to compile.
15    #[error("module compile failed: {0}")]
16    Compile(String),
17
18    /// The module failed to instantiate.
19    #[error("instantiation failed: {0}")]
20    Instantiate(String),
21
22    /// The module is missing a required ABI export (`memory`, `alloc`, `run`).
23    #[error("module is missing required export `{0}`")]
24    MissingExport(&'static str),
25
26    /// Execution trapped — out of fuel, over the memory limit, or an abort. A trap
27    /// is deterministic: every honest host traps at the same point.
28    #[error("execution trapped (out of fuel / memory limit / abort): {0}")]
29    Trap(String),
30
31    /// The module returned something that violates the function ABI.
32    #[error("module violated the function ABI: {0}")]
33    Abi(String),
34
35    /// Fuel accounting was unavailable.
36    #[error("fuel accounting unavailable: {0}")]
37    Fuel(String),
38}