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

Class Error

crates/c-api/include/wasmtime/error.hh:26–55  ·  view source on GitHub ↗

* \brief Errors coming from Wasmtime * * This class represents an error that came from Wasmtime and contains a textual * description of the error that occurred. */

Source from the content-addressed store, hash-verified

24 * description of the error that occurred.
25 */
26class Error {
27 WASMTIME_OWN_WRAPPER(Error, wasmtime_error);
28
29 /// \brief Creates an error with the provided message.
30 Error(const std::string &s) : ptr(wasmtime_error_new(s.c_str())) {}
31
32 /// \brief Returns the error message associated with this error.
33 std::string message() const {
34 wasm_byte_vec_t msg_bytes;
35 wasmtime_error_message(ptr.get(), &msg_bytes);
36 auto ret = std::string(msg_bytes.data, msg_bytes.size);
37 wasm_byte_vec_delete(&msg_bytes);
38 return ret;
39 }
40
41 /// If this trap represents a call to `exit` for WASI, this will return the
42 /// optional error code associated with the exit trap.
43 std::optional<int32_t> i32_exit() const {
44 int32_t status = 0;
45 if (wasmtime_error_exit_status(ptr.get(), &status)) {
46 return status;
47 }
48 return std::nullopt;
49 }
50
51 /// Returns the trace of WebAssembly frames associated with this error.
52 ///
53 /// Note that the `trace` cannot outlive this error object.
54 Trace trace() const;
55};
56
57/// \brief Used to print an error.
58inline std::ostream &operator<<(std::ostream &os, const Error &e) {

Callers 15

createMethod · 0.70
fieldMethod · 0.70
createMethod · 0.70
compileMethod · 0.70
validateMethod · 0.70
deserializeMethod · 0.70
deserialize_fileMethod · 0.70
serializeMethod · 0.70
tagMethod · 0.70
createMethod · 0.70
getMethod · 0.70
setMethod · 0.70

Calls

no outgoing calls

Tested by 1

TESTFunction · 0.40