mirror of
https://github.com/eyre-rs/eyre.git
synced 2025-09-28 05:21:34 +00:00
merge upstream changes from anyhow (#10)
This commit is contained in:
parent
e3bf56ef5c
commit
3ac0be8322
@ -15,10 +15,14 @@ default = ["std"]
|
||||
std = []
|
||||
|
||||
[dev-dependencies]
|
||||
futures = "0.3"
|
||||
futures = { version = "0.3", default-features = false }
|
||||
rustversion = "1.0"
|
||||
thiserror = "1.0"
|
||||
trybuild = { version = "1.0.19", features = ["diff"] }
|
||||
|
||||
[dependencies]
|
||||
indenter = "^0.1.1"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
targets = ["x86_64-unknown-linux-gnu"]
|
||||
rustdoc-args = ["--cfg", "doc_cfg"]
|
||||
|
18
README.md
18
README.md
@ -199,9 +199,21 @@ type Result<T, E = eyre::Report<MyContext>> = core::result::Result<T, E>;
|
||||
}
|
||||
```
|
||||
|
||||
- A backtrace is captured and printed with the error if the underlying error
|
||||
type does not already provide its own. In order to see backtraces, the
|
||||
`RUST_LIB_BACKTRACE=1` environment variable must be defined.
|
||||
- If using the nightly channel, a backtrace is captured and printed with the
|
||||
error if the underlying error type does not already provide its own. In order
|
||||
to see backtraces, they must be enabled through the environment variables
|
||||
described in [`std::backtrace`]:
|
||||
|
||||
- If you want panics and errors to both have backtraces, set
|
||||
`RUST_BACKTRACE=1`;
|
||||
- If you want only errors to have backtraces, set `RUST_LIB_BACKTRACE=1`;
|
||||
- If you want only panics to have backtraces, set `RUST_BACKTRACE=1` and
|
||||
`RUST_LIB_BACKTRACE=0`.
|
||||
|
||||
The tracking issue for this feature is [rust-lang/rust#53487].
|
||||
|
||||
[`std::backtrace`]: https://doc.rust-lang.org/std/backtrace/index.html#environment-variables
|
||||
[rust-lang/rust#53487]: https://github.com/rust-lang/rust/issues/53487
|
||||
|
||||
- Eyre works with any error type that has an impl of `std::error::Error`,
|
||||
including ones defined in your crate. We do not bundle a `derive(Error)` macro
|
||||
|
13
src/error.rs
13
src/error.rs
@ -26,6 +26,7 @@ where
|
||||
/// If the error type does not provide a backtrace, a backtrace will be
|
||||
/// created here to ensure that a backtrace exists.
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg_attr(doc_cfg, doc(cfg(feature = "std")))]
|
||||
pub fn new<E>(error: E) -> Self
|
||||
where
|
||||
E: StdError + Send + Sync + 'static,
|
||||
@ -266,11 +267,19 @@ where
|
||||
/// Backtraces are only available on the nightly channel. Tracking issue:
|
||||
/// [rust-lang/rust#53487][tracking].
|
||||
///
|
||||
/// In order for the backtrace to be meaningful, the environment variable
|
||||
/// `RUST_LIB_BACKTRACE=1` must be defined. Backtraces are somewhat
|
||||
/// In order for the backtrace to be meaningful, one of the two environment
|
||||
/// variables `RUST_LIB_BACKTRACE=1` or `RUST_BACKTRACE=1` must be defined
|
||||
/// and `RUST_LIB_BACKTRACE` must not be `0`. Backtraces are somewhat
|
||||
/// expensive to capture in Rust, so we don't necessarily want to be
|
||||
/// capturing them all over the place all the time.
|
||||
///
|
||||
/// - If you want panics and errors to both have backtraces, set
|
||||
/// `RUST_BACKTRACE=1`;
|
||||
/// - If you want only errors to have backtraces, set
|
||||
/// `RUST_LIB_BACKTRACE=1`;
|
||||
/// - If you want only panics to have backtraces, set `RUST_BACKTRACE=1` and
|
||||
/// `RUST_LIB_BACKTRACE=0`.
|
||||
///
|
||||
/// [tracking]: https://github.com/rust-lang/rust/issues/53487
|
||||
#[cfg(backtrace)]
|
||||
pub fn backtrace(&self) -> &Backtrace {
|
||||
|
19
src/lib.rs
19
src/lib.rs
@ -250,9 +250,21 @@
|
||||
//! # ;
|
||||
//! ```
|
||||
//!
|
||||
//! - A backtrace is captured and printed with the error if the underlying error
|
||||
//! type does not already provide its own. In order to see backtraces, the
|
||||
//! `RUST_LIB_BACKTRACE=1` environment variable must be defined.
|
||||
//! - If using the nightly channel, a backtrace is captured and printed with the
|
||||
//! error if the underlying error type does not already provide its own. In
|
||||
//! order to see backtraces, they must be enabled through the environment
|
||||
//! variables described in [`std::backtrace`]:
|
||||
//!
|
||||
//! - If you want panics and errors to both have backtraces, set
|
||||
//! `RUST_BACKTRACE=1`;
|
||||
//! - If you want only errors to have backtraces, set `RUST_LIB_BACKTRACE=1`;
|
||||
//! - If you want only panics to have backtraces, set `RUST_BACKTRACE=1` and
|
||||
//! `RUST_LIB_BACKTRACE=0`.
|
||||
//!
|
||||
//! The tracking issue for this feature is [rust-lang/rust#53487].
|
||||
//!
|
||||
//! [`std::backtrace`]: https://doc.rust-lang.org/std/backtrace/index.html#environment-variables
|
||||
//! [rust-lang/rust#53487]: https://github.com/rust-lang/rust/issues/53487
|
||||
//!
|
||||
//! - Eyre works with any error type that has an impl of `std::error::Error`,
|
||||
//! including ones defined in your crate. We do not bundle a `derive(Error)`
|
||||
@ -316,6 +328,7 @@
|
||||
|
||||
#![doc(html_root_url = "https://docs.rs/eyre/0.3.8")]
|
||||
#![cfg_attr(backtrace, feature(backtrace))]
|
||||
#![cfg_attr(doc_cfg, feature(doc_cfg))]
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
#![allow(
|
||||
clippy::needless_doctest_main,
|
||||
|
Loading…
x
Reference in New Issue
Block a user