A custom context for [eyre
] that captures a Backtrace
on stable.
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
].
rust
pub type Report = eyre::Report<Context>;
pub type Result<T, E = Report> = core::result::Result<T, E>;
Add the following to your toml file:
toml
[dependencies]
eyre = "0.3.8"
stable-eyre = "0.1"
And then import the type alias from color-eyre for [eyre::Report
] or [eyre::Result
].
```rust use stable_eyre::Report;
// or
fn example(&self) -> stable_eyre::Result<()> { // ... } ```
```rust use eyre::WrapErr; use stable_eyre::Report;
fn main() -> Result<(), Report> { Ok(read_config()?) }
fn readfile(path: &str) -> Result<(), Report> { Ok(std::fs::readto_string(path).map(drop)?) }
fn readconfig() -> Result<(), Report> { readfile("fakefile") .wraperr("Unable to read config") } ```
Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.