mirror of
https://github.com/eyre-rs/eyre.git
synced 2025-09-28 05:21:34 +00:00
color-eyre
A custom context for the eyre
crate for colorful error reports, suggestions,
and tracing-error
support.
Disclaimer: This crate is currently pre-release while I try to upstream
changes I made to color-backtrace
to support this crate. Until then I
cannot publish this to crates.io, the documentation is filled out however so
simply run cargo doc --open
for an explanation of usage.
Explanation
This crate works by defining a Context
type which implements EyreContext
and a pair of type aliases for setting this context object as the parameter of
eyre::Report
.
pub type Report = eyre::Report<Context>;
pub type Result<T, E = Report> = core::result::Result<T, E>;
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 from both of the above libraries - store help text via
Help
trait and display after final report
Setup
Add the following to your toml file:
[dependencies]
eyre = "0.3.8"
color-eyre = "0.2.0"
And then import the type alias from color-eyre for Report
or Result
.
use color_eyre::Report;
// or
fn example(&self) -> color_eyre::Result<()> {
// ...
}
Minimal Report Format
Short Report Format (with RUST_LIB_BACKTRACE=1
)
Full Report Format (with RUST_LIB_BACKTRACE=full
)
Description
A trait object based error handling type for easy idiomatic error handling and reporting in Rust applications
Languages
Rust
98.6%
Python
1.3%