Module wasmer_c_api::wasm_c_api::trap
source · Expand description
A trap represents an error which stores trace message with backtrace.
§Example
int main() {
// Create an engine and a store.
wasm_engine_t* engine = wasm_engine_new();
wasm_store_t* store = wasm_store_new(engine);
// Create the trap message.
wasm_message_t message;
wasm_name_new_from_string_nt(&message, "foobar");
// Create the trap with its message.
// The backtrace will be generated automatically.
wasm_trap_t* trap = wasm_trap_new(store, &message);
assert(trap);
wasm_name_delete(&message);
// Do something with the trap.
// Free everything.
wasm_trap_delete(trap);
wasm_store_delete(store);
wasm_engine_delete(engine);
return 0;
}
Usually, a trap is returned from a host function (an imported function).
cbindgen:ignore
Structs§
Functions§
- Deletes a trap.
- Gets the message attached to the trap.
- Create a new trap message.
- Gets the origin frame attached to the trap.
- Gets the trace (as a list of frames) attached to the trap.