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

@@ -123,7 +123,7 @@ impl WastContext {
fn module(&mut self, instance_name: Option<&str>, module: &[u8]) -> Result<()> {
let instance = match self.instantiate(module)? {
Outcome::Ok(i) => i,
Outcome::Trap(e) => bail!("instantiation failed: {}", e.message()),
Outcome::Trap(e) => return Err(e).context("instantiation failed"),
};
if let Some(name) = instance_name {
self.linker.instance(name, &instance)?;
@@ -189,7 +189,7 @@ impl WastContext {
Outcome::Ok(values) => bail!("expected trap, got {:?}", values),
Outcome::Trap(t) => t,
};
let actual = trap.message();
let actual = trap.to_string();
if actual.contains(expected)
// `bulk-memory-operations/bulk.wast` checks for a message that
// specifies which element is uninitialized, but our traps don't