Don't render errors twice, only once (#773)

Change a `bail!` macro which renders the debug representation of an
error to a call to `context` which preserves the original error object
and improves rendering later on down the road.
This commit is contained in:
Alex Crichton
2020-01-07 16:29:51 -06:00
committed by GitHub
parent 045d6a7310
commit b46f26361f

View File

@@ -264,10 +264,10 @@ impl RunCommand {
})
.collect::<Result<Vec<_>, _>>()?;
let instance = HostRef::new(match Instance::new(store, &module, &imports) {
Ok(instance) => instance,
Err(trap) => bail!("Failed to instantiate {:?}: {:?}", path, trap),
});
let instance = HostRef::new(
Instance::new(store, &module, &imports)
.context(format!("failed to instantiate {:?}", path))?,
);
Ok((instance, module, data))
}