Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Give accessors to wasmtime::Trap causes #3033

Merged
merged 1 commit into from
Jun 30, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
bnjbvr marked this conversation as resolved.
Show resolved Hide resolved
///
/// 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