alexcrichton commented on Issue #1792:
This is actually intentional I believe that
Display for T
whereT: Error
should only print one "stack frame" of error. The full backtrace of errors (causes) should be printed elsewhere. The connection viafn source
should cause other libraries, likeanyhow
print the full list of causes. Could you elaborate a bit on how this came up for you?
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:
- peterhuene: wasmtime:api
To subscribe or unsubscribe from this label, edit the <code>.github/subscribe-to-label.json</code> configuration file.
Learn more.
</details>
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 thisDisplay
impl was removed and inlined there.
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 ifTrap
printed out its own backtrace of errors, because then it would be incompatible with crates likeanyhow
which assume errors don't do that.
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 theDisplay
forTrapReason
andTrap
, as convenience so this can be justformat!("{:#}", trap)
.
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 theDisplay
forTrapReason
andTrap
, as convenience so this can be justformat!("{:#}", trap)
?
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 likeanyhow::Error
which explicitly has support for this (or convert toBox<Error + ...>
)
leoyvens commented on Issue #1792:
Alright, closing this then, thanks for the explanations.
Last updated: Nov 22 2024 at 17:03 UTC