Skip to content

Commit

Permalink
Add a way to display only the trap's reason (without the backtrace)
Browse files Browse the repository at this point in the history
  • Loading branch information
bnjbvr committed Jun 28, 2021
1 parent 7ce4604 commit 47cb398
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions crates/wasmtime/src/trap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,16 @@ impl Trap {
}
}

/// Displays the error reason for this trap.
///
/// In particular, it differs from this struct's `Display` by *only*
/// showing the reason, and not the full backtrace. This is useful to
/// customize the way the trap is reported, for instance to display a short
/// message for user-facing errors.
pub fn display_reason<'a>(&'a self) -> impl fmt::Display + 'a {
&self.inner.reason
}

/// Returns a list of function frames in WebAssembly code that led to this
/// trap happening.
pub fn trace(&self) -> &[FrameInfo] {
Expand Down

0 comments on commit 47cb398

Please sign in to comment.