Lines
90 %
Functions
100 %
Branches
//! Script-raise host native: the boundary bridge for in-guest raises.
//!
//! Since Tier 3.2, `(error 'code "msg" [detail])` and engine errors (commodity
//! mismatch) `throw $nomi_error` in-guest; this host fn is not the raise
//! primitive but the BOUNDARY BRIDGE (ADR-0026): the compiler wraps each
//! host-invoked body in a `try_table` that catches any uncaught `$nomi_error`,
//! reads its `code`/`message`/`detail`, and `call $__nomi_raise`s here. The fn
//! never returns normally; it always produces a [`scripting::runtime::ScriptRaise`]
//! error that [`scripting::runtime::classify_runtime_error`] lifts into a
//! `ScriptRaised { code, message, detail }` for the wire envelope.
use wasmtime::{AnyRef, ArrayRef, Caller, Linker, Rooted};
use crate::session::SessionData;
pub const REGISTERED_COMMANDS: &[&str] = &["error"];
pub fn register(linker: &mut Linker<SessionData>) -> wasmtime::Result<()> {
linker.func_wrap(
"nomi",
"__nomi_raise",
|mut caller: Caller<'_, SessionData>,
code: Option<Rooted<ArrayRef>>,
message: Option<Rooted<ArrayRef>>,
detail: Option<Rooted<AnyRef>>|
-> wasmtime::Result<()> {
scripting::runtime::nomi_raise(&mut caller, code, message, detail)
},
)?;
Ok(())
}