provide feature to use eyre instead of anyhow #85
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds the
anyhow
andeyre
features to all crates using anyhow for errors.anyhow
is added todefault
so nothing changes for standard workflows. Caveat:anyhow
does not allow to opt out ofstd
.What do you think? Does this fit into your design?
Background: I want to use
eyre
incnidarium
and other crates that astria's Sequencer depends on (hence this PR targettingibc-types
, which are a blocker for cnidarium to migrate). We are using an eyre error hook [1] in our services to customize our errorDisplay
formatting in order to get full source-chains emitted in tracing events. There are two reasons for this:Value
only fordyn std::error::Error
. So in order to get full error backtraces (while avoiding debug formatting), one needs to convert the anyhow error to a trait object using a clunkyerror = AsRef::<dyn std::error::Error>::as_ref(&the_error)
.Json
one) don't follow the source-chain, only printing the top-most context. There is a PR sitting idle for 6 months now and is not being merged [2].Because of these 2 issues we customized the error hook lest we miss out on important information.
1: https://github.com/astriaorg/astria/blob/6f13e7f126c7df35c764cae309f79fa28090028c/crates/astria-eyre/src/lib.rs#L27
2: tokio-rs/tracing#2797