Stream: git-wasmtime

Topic: wasmtime / Issue #1792 print TrapReason::Error causes


view this post on Zulip Wasmtime GitHub notifications bot (May 30 2020 at 00:22):

alexcrichton commented on Issue #1792:

This is actually intentional I believe that Display for T where T: Error should only print one "stack frame" of error. The full backtrace of errors (causes) should be printed elsewhere. The connection via fn source should cause other libraries, like anyhow print the full list of causes. Could you elaborate a bit on how this came up for you?

view this post on Zulip Wasmtime GitHub notifications bot (May 30 2020 at 00:40):

github-actions[bot] commented on Issue #1792:

Subscribe to Label Action

cc @peterhuene

<details>
This issue or pull request has been labeled: "wasmtime:api"

Thus the following users have been cc'd because of the following labels:

To subscribe or unsubscribe from this label, edit the <code>.github/subscribe-to-label.json</code> configuration file.

Learn more.
</details>

view this post on Zulip Wasmtime GitHub notifications bot (May 30 2020 at 00:40):

leoyvens commented on Issue #1792:

@alexcrichton It didn't actually come up for me, but I think the full information is what we want in the context of this impl. The only use of this Display impl is here https://github.com/bytecodealliance/wasmtime/blob/master/crates/wasmtime/src/trap.rs#L190 where we proceed to print the full WASM backtrace, and therefore are probably also interested in the full list of causes. It might be clearer if this Display impl was removed and inlined there.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 01 2020 at 15:11):

alexcrichton commented on Issue #1792:

The purpose of Display for each error in the backtrace of errors is to print just that specific error. Part of wasm errors is the wasm callstack, so they're printed with wasm traps. Idiomatic error handling in Rust would not work if Trap printed out its own backtrace of errors, because then it would be incompatible with crates like anyhow which assume errors don't do that.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 01 2020 at 15:22):

leoyvens commented on Issue #1792:

@alexcrichton I think I get it, so if I want to print causes, I should do something like:

format!("{:#}", anyhow::Error::from(trap));

And we don't want that to print the causes twice.

Would it make sense to support {:#} directly in the Display for TrapReason and Trap, as convenience so this can be just format!("{:#}", trap).

view this post on Zulip Wasmtime GitHub notifications bot (Jun 01 2020 at 15:23):

leoyvens edited a comment on Issue #1792:

@alexcrichton I think I get it, so if I want to print causes, I should do something like:

format!("{:#}", anyhow::Error::from(trap));

And we don't want that to print the causes twice.

Would it make sense to support {:#} directly in the Display for TrapReason and Trap, as convenience so this can be just format!("{:#}", trap)?

view this post on Zulip Wasmtime GitHub notifications bot (Jun 01 2020 at 15:53):

alexcrichton commented on Issue #1792:

AFAIK most types implementing Error do not support the ability to print their full backtrace. To do that you need to either write your own function or use a catch-all error type like anyhow::Error which explicitly has support for this (or convert to Box<Error + ...>)

view this post on Zulip Wasmtime GitHub notifications bot (Jun 01 2020 at 16:19):

leoyvens commented on Issue #1792:

Alright, closing this then, thanks for the explanations.


Last updated: Dec 23 2024 at 12:05 UTC