From b46f26361f89d753cfdee79c9cd7cc57d89d14fd Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 7 Jan 2020 16:29:51 -0600 Subject: [PATCH] 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. --- src/commands/run.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/commands/run.rs b/src/commands/run.rs index cafd7f19f8..2ddf47fe00 100644 --- a/src/commands/run.rs +++ b/src/commands/run.rs @@ -264,10 +264,10 @@ impl RunCommand { }) .collect::, _>>()?; - 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)) }