impl From<anyhow::Error> for Trap (#1753)
* From<anyhow::Error> for Trap * Add TrapReason::Error * wasmtime: Improve Error to Trap conversion * Remove Trap::message
This commit is contained in:
@@ -10,8 +10,8 @@ pub struct wasmtime_error_t {
|
||||
wasmtime_c_api_macros::declare_own!(wasmtime_error_t);
|
||||
|
||||
impl wasmtime_error_t {
|
||||
pub(crate) fn to_trap(&self) -> Box<wasm_trap_t> {
|
||||
Box::new(wasm_trap_t::new(Trap::new(format!("{:?}", self.error))))
|
||||
pub(crate) fn to_trap(self) -> Box<wasm_trap_t> {
|
||||
Box::new(wasm_trap_t::new(Trap::from(self.error)))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ pub extern "C" fn wasm_trap_new(
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wasm_trap_message(trap: &wasm_trap_t, out: &mut wasm_message_t) {
|
||||
let mut buffer = Vec::new();
|
||||
buffer.extend_from_slice(trap.trap.borrow().message().as_bytes());
|
||||
buffer.extend_from_slice(trap.trap.borrow().to_string().as_bytes());
|
||||
buffer.reserve_exact(1);
|
||||
buffer.push(0);
|
||||
out.set_buffer(buffer);
|
||||
|
||||
Reference in New Issue
Block a user