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 authored Jun 30, 2021
1 parent a3e08ee commit a603fc5
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 a603fc5

Please sign in to comment.