mirror of
https://github.com/eyre-rs/eyre.git
synced 2025-09-27 21:14:34 +00:00
bump indenter dep version and update readme
* Update testing * dont bother testing no_std yet ... * bump version for new release with fixed indenter * add documentation about custom context crates
This commit is contained in:
parent
dbc3cc181e
commit
86c1267aab
48
.github/workflows/ci.yml
vendored
48
.github/workflows/ci.yml
vendored
@ -1,4 +1,8 @@
|
||||
on: [push, pull_request]
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request: {}
|
||||
|
||||
name: Continuous integration
|
||||
|
||||
@ -20,14 +24,33 @@ jobs:
|
||||
with:
|
||||
command: check
|
||||
|
||||
test:
|
||||
test-features:
|
||||
name: Test Suite
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
override: true
|
||||
- uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: test
|
||||
- uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: test
|
||||
args: --all-features
|
||||
|
||||
test-versions:
|
||||
name: Test Suite
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
rust:
|
||||
- stable
|
||||
- beta
|
||||
- nightly
|
||||
- 1.39.0
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- uses: actions-rs/toolchain@v1
|
||||
@ -37,10 +60,23 @@ jobs:
|
||||
- uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: test
|
||||
# - uses: actions-rs/cargo@v1
|
||||
# with:
|
||||
# command: test
|
||||
# args: --no-default-features
|
||||
|
||||
test-os:
|
||||
name: Test Suite
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest, macOS-latest]
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
profile: minimal
|
||||
override: true
|
||||
- uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: test
|
||||
|
||||
fmt:
|
||||
name: Rustfmt
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "eyre"
|
||||
version = "0.4.1" # remember to update html_root_url
|
||||
version = "0.4.2" # remember to update html_root_url
|
||||
authors = ["David Tolnay <dtolnay@gmail.com>", "Jane Lusby <jlusby42@gmail.com>"]
|
||||
edition = "2018"
|
||||
license = "MIT OR Apache-2.0"
|
||||
@ -23,7 +23,7 @@ backtrace = "0.3.46"
|
||||
anyhow = "1.0.28"
|
||||
|
||||
[dependencies]
|
||||
indenter = "0.2.0"
|
||||
indenter = "0.3.0"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
32
README.md
32
README.md
@ -11,9 +11,28 @@ applications.
|
||||
|
||||
This crate is a fork of [`anyhow`] by @dtolnay with a support for customized
|
||||
`Reports`. For more details on customization checkout the docs on
|
||||
[`eyre::EyreContext`]. For an example on how to implement a custom context
|
||||
check out [`stable-eyre`] which implements a minimal custom context for
|
||||
capturing backtraces on stable.
|
||||
[`eyre::EyreContext`].
|
||||
|
||||
## Custom Contexts
|
||||
|
||||
The heart of this crate is it's ability to swap out the Context type to change
|
||||
what information is carried alongside errors and how the end report is
|
||||
formatted. This crate is meant to be used alongside companion crates that
|
||||
customize its behavior. Below is a list of known custom context crates and
|
||||
short summaries of what features they provide.
|
||||
|
||||
- [`stable-eyre`]: Switches the backtrace type from `std`'s to `backtrace-rs`'s
|
||||
so that it can be captured on stable. The report format is identical to
|
||||
`DefaultContext`'s report format.
|
||||
- [`color-eyre`]: Captures a `backtrace::Backtrace` and a
|
||||
`tracing_error::SpanTrace`. Provides a `Help` trait for attaching warnings
|
||||
and suggestions to error reports. The end report is then pretty printed with
|
||||
the help of [`color-backtrace`], [`color-spantrace`], and `ansi_term`. Check
|
||||
out the README on [`color-eyre`] for screenshots of the report format.
|
||||
- [`simple-eyre`]: A minimal `EyreContext` that captures no additional
|
||||
information, for when you do not wish to capture `Backtrace`s with errors.
|
||||
- [`jane-eyre`]: A custom context type that exists purely for the pun.
|
||||
Currently just re-exports `color-eyre`.
|
||||
|
||||
## Details
|
||||
|
||||
@ -229,7 +248,12 @@ implements `context` for options which you can import to make existing
|
||||
[`anyhow::Context`]: https://docs.rs/anyhow/*/anyhow/trait.Context.html
|
||||
[`anyhow`]: https://github.com/dtolnay/anyhow
|
||||
[`tracing_error::SpanTrace`]: https://docs.rs/tracing-error/*/tracing_error/struct.SpanTrace.html
|
||||
[`stable-eyre`]: https://docs.rs/stable-eyre
|
||||
[`stable-eyre`]: https://github.com/yaahc/stable-eyre
|
||||
[`color-eyre`]: https://github.com/yaahc/color-eyre
|
||||
[`jane-eyre`]: https://github.com/yaahc/jane-eyre
|
||||
[`simple-eyre`]: https://github.com/yaahc/simple-eyre
|
||||
[`color-spantrace`]: https://github.com/yaahc/color-spantrace
|
||||
[`color-backtrace`]: https://github.com/athre0z/color-backtrace
|
||||
[actions-badge]: https://github.com/yaahc/eyre/workflows/Continuous%20integration/badge.svg
|
||||
[actions-url]: https://github.com/yaahc/eyre/actions?query=workflow%3A%22Continuous+integration%22
|
||||
|
||||
|
39
src/lib.rs
39
src/lib.rs
@ -1,15 +1,36 @@
|
||||
//! This library provides [`eyre::Report`][Report], a trait object based error
|
||||
//! type for easy idiomatic error handling in Rust applications.
|
||||
//!
|
||||
//! This crate is a fork of [`anyhow`] by @dtolnay with a support for customized `Reports`. For
|
||||
//! more details on customization checkout the docs on [`eyre::EyreContext`]. For an example on how
|
||||
//! to implement a custom context check out [`stable-eyre`] which implements a minimal custom
|
||||
//! context for capturing backtraces on stable.
|
||||
//! This crate is a fork of [`anyhow`] by @dtolnay with a support for customized
|
||||
//! `Reports`. For more details on customization checkout the docs on
|
||||
//! [`eyre::EyreContext`].
|
||||
//!
|
||||
//! ```toml
|
||||
//! [dependencies]
|
||||
//! eyre = "0.4"
|
||||
//! ```
|
||||
//!
|
||||
//! ## Custom Contexts
|
||||
//!
|
||||
//! The heart of this crate is it's ability to swap out the Context type to change
|
||||
//! what information is carried alongside errors and how the end report is
|
||||
//! formatted. This crate is meant to be used alongside companion crates that
|
||||
//! customize its behavior. Below is a list of known custom context crates and
|
||||
//! short summaries of what features they provide.
|
||||
//!
|
||||
//! - [`stable-eyre`]: Switches the backtrace type from `std`'s to `backtrace-rs`'s
|
||||
//! so that it can be captured on stable. The report format is identical to
|
||||
//! `DefaultContext`'s report format.
|
||||
//! - [`color-eyre`]: Captures a `backtrace::Backtrace` and a
|
||||
//! `tracing_error::SpanTrace`. Provides a `Help` trait for attaching warnings
|
||||
//! and suggestions to error reports. The end report is then pretty printed with
|
||||
//! the help of [`color-backtrace`], [`color-spantrace`], and `ansi_term`. Check
|
||||
//! out the README on [`color-eyre`] for screenshots of the report format.
|
||||
//! - [`simple-eyre`]: A minimal `EyreContext` that captures no additional
|
||||
//! information, for when you do not wish to capture `Backtrace`s with errors.
|
||||
//! - [`jane-eyre`]: A custom context type that exists purely for the pun.
|
||||
//! Currently just re-exports `color-eyre`.
|
||||
//!
|
||||
//! ## Details
|
||||
//!
|
||||
//! - Use `Result<T, eyre::Report>`, or equivalently `eyre::Result<T>`, as
|
||||
@ -265,14 +286,20 @@
|
||||
//! However, to help with porting we do provide a `ContextCompat` trait which
|
||||
//! implements `context` for options which you can import to make existing
|
||||
//! `.context` calls compile.
|
||||
//!
|
||||
//! [Report]: https://docs.rs/eyre/*/eyre/struct.Report.html
|
||||
//! [`eyre::EyreContext`]: https://docs.rs/eyre/*/eyre/trait.EyreContext.html
|
||||
//! [`eyre::WrapErr`]: https://docs.rs/eyre/*/eyre/trait.WrapErr.html
|
||||
//! [`anyhow::Context`]: https://docs.rs/anyhow/*/anyhow/trait.Context.html
|
||||
//! [`anyhow`]: https://github.com/dtolnay/anyhow
|
||||
//! [`tracing_error::SpanTrace`]: https://docs.rs/tracing-error/*/tracing_error/struct.SpanTrace.html
|
||||
//! [`stable_eyre`]: https://docs.rs/stable-eyre
|
||||
#![doc(html_root_url = "https://docs.rs/eyre/0.4.1")]
|
||||
//! [`stable-eyre`]: https://github.com/yaahc/stable-eyre
|
||||
//! [`color-eyre`]: https://github.com/yaahc/color-eyre
|
||||
//! [`jane-eyre`]: https://github.com/yaahc/jane-eyre
|
||||
//! [`simple-eyre`]: https://github.com/yaahc/simple-eyre
|
||||
//! [`color-spantrace`]: https://github.com/yaahc/color-spantrace
|
||||
//! [`color-backtrace`]: https://github.com/athre0z/color-backtrace
|
||||
#![doc(html_root_url = "https://docs.rs/eyre/0.4.2")]
|
||||
#![warn(
|
||||
missing_debug_implementations,
|
||||
missing_docs,
|
||||
|
@ -38,3 +38,18 @@ fn test_boxed_eyre() {
|
||||
let error = eyre!(error);
|
||||
assert_eq!("oh no!", error.source().unwrap().to_string());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_boxed_sources() {
|
||||
let error = MyError {
|
||||
source: io::Error::new(io::ErrorKind::Other, "oh no!"),
|
||||
};
|
||||
let error = Box::<dyn StdError + Send + Sync>::from(error);
|
||||
let error: Report = eyre!(error).wrap_err("it failed");
|
||||
assert_eq!("it failed", error.to_string());
|
||||
assert_eq!("outer", error.source().unwrap().to_string());
|
||||
assert_eq!(
|
||||
"oh no!",
|
||||
error.source().unwrap().source().unwrap().to_string()
|
||||
);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user