jameysharp commented on issue #6782:
Thanks for suggesting an improvement to error reporting! But I'm confused by this change.
.with_context
is supposed to add context to the error, not replace it. So the message ine.to_string()
should already be available from the returned error. See the documentation onanyhow::Context
.I suspect if you didn't see the "Caused by:" chain in the error output, then the root issue here is that something is not printing errors in the right way. Can you provide more information about what you tried and what output you got?
zarkone commented on issue #6782:
@jameysharp you are right, thank you! That was not obvious to me. Sorry for rubberducking you instead of reading the docs >..<
For the context (pun intended),
anyhow::Context
prints onlycontext
part of error usingDisplay
printer{}
. In order to print full info, including "source",{:#}
should be used.https://docs.rs/anyhow/latest/anyhow/struct.Error.html#display-representations
zarkone edited a comment on issue #6782:
@jameysharp you are right, thank you! That was not obvious to me. Sorry for rubberducking you instead of reading the docs >..<
For the context (pun intended),
anyhow::Error
prints onlycontext
part of error usingDisplay
printer{}
. In order to print full info, including "source",{:#}
should be used.https://docs.rs/anyhow/latest/anyhow/struct.Error.html#display-representations
Last updated: Nov 22 2024 at 16:03 UTC