This commit is contained in:
Sergey Pepyakin 2018-02-05 20:38:17 +03:00
parent 2b80a98b7f
commit be5169a25f
2 changed files with 8 additions and 7 deletions

View File

@ -132,10 +132,10 @@ impl FuncInstance {
/// # Errors
///
/// Returns `Err` if `args` types is not match function [`signature`] or
/// if [`TrapKind`] at execution time occured.
/// if [`Trap`] at execution time occured.
///
/// [`signature`]: #method.signature
/// [`TrapKind`]: #enum.TrapKind.html
/// [`Trap`]: #enum.Trap.html
pub fn invoke<E: Externals>(
func: &FuncRef,
args: &[RuntimeValue],

View File

@ -127,9 +127,10 @@ impl Trap {
}
/// Error type which can thrown by wasm code or by host environment.
///
/// Under some conditions, wasm execution may produce a `TrapKind`, which immediately aborts execution.
/// TrapKinds can't be handled by WebAssembly code, but are reported to the embedder.
///
/// See [`Trap`] for details.
///
/// [`Trap`]: struct.Trap.html
#[derive(Debug)]
pub enum TrapKind {
/// Wasm code executed `unreachable` opcode.
@ -275,7 +276,7 @@ impl fmt::Display for Error {
Error::Memory(ref s) => write!(f, "Memory: {}", s),
Error::Global(ref s) => write!(f, "Global: {}", s),
Error::Value(ref s) => write!(f, "Value: {}", s),
Error::Trap(ref s) => write!(f, "TrapKind: {:?}", s),
Error::Trap(ref s) => write!(f, "Trap: {:?}", s),
Error::Host(ref e) => write!(f, "User: {}", e),
}
}
@ -291,7 +292,7 @@ impl error::Error for Error {
Error::Memory(ref s) => s,
Error::Global(ref s) => s,
Error::Value(ref s) => s,
Error::Trap(_) => "TrapKind",
Error::Trap(_) => "Trap",
Error::Host(_) => "Host error",
}
}