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 /// # Errors
/// ///
/// Returns `Err` if `args` types is not match function [`signature`] or /// 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 /// [`signature`]: #method.signature
/// [`TrapKind`]: #enum.TrapKind.html /// [`Trap`]: #enum.Trap.html
pub fn invoke<E: Externals>( pub fn invoke<E: Externals>(
func: &FuncRef, func: &FuncRef,
args: &[RuntimeValue], args: &[RuntimeValue],

View File

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