MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / wasmtime_error_new

Function wasmtime_error_new

crates/c-api/src/error.rs:24–30  ·  view source on GitHub ↗
(
    msg: *const std::ffi::c_char,
)

Source from the content-addressed store, hash-verified

22
23#[unsafe(no_mangle)]
24pub extern "C" fn wasmtime_error_new(
25 msg: *const std::ffi::c_char,
26) -> Option<Box<wasmtime_error_t>> {
27 let msg_bytes = unsafe { std::ffi::CStr::from_ptr(msg).to_bytes() };
28 let msg_string = String::from_utf8_lossy(msg_bytes).into_owned();
29 Some(Box::new(wasmtime_error_t::from(format_err!(msg_string))))
30}
31
32pub(crate) fn handle_result<T>(
33 result: Result<T>,

Callers 1

ErrorMethod · 0.85

Calls 4

fromFunction · 0.85
into_ownedMethod · 0.80
newFunction · 0.50
to_bytesMethod · 0.45

Tested by

no test coverage detected