Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
executor: Improve FunctionExecution error messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
jimpo committed Oct 21, 2019
1 parent b23af94 commit 6d24b24
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 7 deletions.
4 changes: 2 additions & 2 deletions core/executor/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ pub enum Error {
#[display(fmt="Requested allocation size is too large")]
RequestedAllocationTooLarge,
/// Execution of a host function failed.
#[display(fmt="Function execution failed with: {}", _0)]
FunctionExecution(String),
#[display(fmt="Host function {} execution failed with: {}", _0, _1)]
FunctionExecution(String, String),
}

impl std::error::Error for Error {
Expand Down
2 changes: 1 addition & 1 deletion core/executor/src/wasmi_execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ impl wasmi::Externals for FunctionExecutor {
)?;

function.execute(self, &mut args)
.map_err(Error::FunctionExecution)
.map_err(|msg| Error::FunctionExecution(function.name().to_string(), msg))
.map_err(wasmi::Trap::from)
.map(|v| v.map(Into::into))
}
Expand Down
2 changes: 1 addition & 1 deletion core/executor/src/wasmtime/function_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ impl<'a> SandboxCapabilities for FunctionExecutor<'a> {
values_vec.as_mut_ptr() as *mut u8,
)
} {
return Err(Error::FunctionExecution(message));
return Err(Error::Other(message));
}

// Load the return value out of `values_vec`.
Expand Down
4 changes: 1 addition & 3 deletions core/executor/src/wasmtime/trampoline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,7 @@ unsafe fn stub_fn_inner(

// Execute and write output back to the stack.
let return_val = func.execute(&mut context, &mut args)
.map_err(|e| Error::FunctionExecution(
format!("error in external function {}: {}", func.name(), e)
))?;
.map_err(|e| Error::FunctionExecution(func.name().to_string(), e))?;
if let Some(val) = return_val {
write_value_to(values_vec, val);
}
Expand Down

0 comments on commit 6d24b24

Please sign in to comment.