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:
Leonardo Yvens
2020-05-29 17:24:12 -03:00
committed by GitHub
parent 8fce8ddefc
commit 0b3b9c298e
11 changed files with 74 additions and 65 deletions

View File

@@ -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)))
}
}