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

Class TrapError

crates/c-api/include/wasmtime/trap.hh:153–172  ·  view source on GitHub ↗

Structure used to represent either a `Trap` or an `Error`.

Source from the content-addressed store, hash-verified

151
152/// Structure used to represent either a `Trap` or an `Error`.
153struct TrapError {
154 /// Storage for what this trap represents.
155 std::variant<Trap, Error> data;
156
157 /// Creates a new `TrapError` from a `Trap`
158 TrapError(Trap t) : data(std::move(t)) {}
159 /// Creates a new `TrapError` from an `Error`
160 TrapError(Error e) : data(std::move(e)) {}
161
162 /// Dispatches internally to return the message associated with this error.
163 std::string message() const {
164 if (const auto *trap = std::get_if<Trap>(&data)) {
165 return trap->message();
166 }
167 if (const auto *error = std::get_if<Error>(&data)) {
168 return std::string(error->message());
169 }
170 std::abort();
171 }
172};
173
174/// Result used by functions which can fail because of invariants being violated
175/// (such as a type error) as well as because of a WebAssembly trap.

Callers 4

createMethod · 0.85
callMethod · 0.85
callMethod · 0.85
instantiateMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected