color-eyre
A custom context for the eyre
crate for colorful error reports, suggestions,
and tracing-error
support.
Setup
Add the following to your toml file:
[]
= "0.4"
= "0.3"
And then import the type alias from color-eyre for eyre::Report
or eyre::Result
.
use Report;
// or
Disabling tracing support
If you don't plan on using tracing_error
and SpanTrace
you can disable the
tracing integration to cut down on unused dependencies:
[]
= "0.4"
= { = "0.3", = false }
Example
use ;
use WrapErr;
use ;
use ErrorLayer;
use *;
use ;
Minimal Report Format
Short Report Format (with RUST_LIB_BACKTRACE=1
)
Full Report Format (with RUST_LIB_BACKTRACE=full
)
Explanation
This crate works by defining a Context
type which implements eyre::EyreContext
and a pair of type aliases for setting this context type as the parameter of
eyre::Report
.
use Context;
pub type Report = Report;
pub type Result<T, E = Report> = Result;
Features
- captures a
backtrace::Backtrace
and prints usingcolor-backtrace
- captures a
tracing_error::SpanTrace
and prints usingcolor-spantrace
- Only capture SpanTrace by default for better performance.
- display source lines when
RUST_LIB_BACKTRACE=full
is set - store help text via
Help
trait and display after final report