Implement Error for Trap.

This commit is contained in:
Sergey Pepyakin 2018-03-11 18:50:17 +01:00
parent 7c88c6ad65
commit 0020d16618
1 changed files with 12 additions and 0 deletions

View File

@ -134,6 +134,18 @@ impl Trap {
}
}
impl fmt::Display for Trap {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "Trap: {:?}", self.kind)
}
}
impl error::Error for Trap {
fn description(&self) -> &str {
"runtime trap"
}
}
/// Error type which can thrown by wasm code or by host environment.
///
/// See [`Trap`] for details.