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:
@@ -181,7 +181,7 @@ fn trap_smoke() -> Result<()> {
|
||||
let store = Store::default();
|
||||
let f = Func::wrap(&store, || -> Result<(), Trap> { Err(Trap::new("test")) });
|
||||
let err = f.call(&[]).unwrap_err().downcast::<Trap>()?;
|
||||
assert_eq!(err.message(), "test");
|
||||
assert!(err.to_string().contains("test"));
|
||||
assert!(err.i32_exit_status().is_none());
|
||||
Ok(())
|
||||
}
|
||||
@@ -203,7 +203,7 @@ fn trap_import() -> Result<()> {
|
||||
.err()
|
||||
.unwrap()
|
||||
.downcast::<Trap>()?;
|
||||
assert_eq!(trap.message(), "foo");
|
||||
assert!(trap.to_string().contains("foo"));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -397,9 +397,8 @@ fn func_write_nothing() -> anyhow::Result<()> {
|
||||
let ty = FuncType::new(Box::new([]), Box::new([ValType::I32]));
|
||||
let f = Func::new(&store, ty, |_, _, _| Ok(()));
|
||||
let err = f.call(&[]).unwrap_err().downcast::<Trap>()?;
|
||||
assert_eq!(
|
||||
err.message(),
|
||||
"function attempted to return an incompatible value"
|
||||
);
|
||||
assert!(err
|
||||
.to_string()
|
||||
.contains("function attempted to return an incompatible value"));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user