Skip to content
Myr

Explain backtrace env variable combinations

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Tolnay · committed by David Tolnay · parent c01ceaf · Browse files · 3 files+31 added−6 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+31 added−6 removed

  • other:+31 added−6 removed

3 files+31 added−6 removed

modified:src/error.rs+10 added-2 removed
288 unmodified lines
289 ///290 /// Backtraces are only available on the nightly channel. Tracking issue:291 /// [rust-lang/rust#53487][tracking].292 ///293 /// In order for the backtrace to be meaningful, the environment variable294 /// `RUST_LIB_BACKTRACE=1` must be defined. Backtraces are somewhat293 /// In order for the backtrace to be meaningful, one of the two environment294 /// variables `RUST_LIB_BACKTRACE=1` or `RUST_BACKTRACE=1` must be defined295 /// and `RUST_LIB_BACKTRACE` must not be `0`. Backtraces are somewhat296 /// expensive to capture in Rust, so we don't necessarily want to be297 /// capturing them all over the place all the time.298 ///299 /// - If you want panics and errors to both have backtraces, set300 /// `RUST_BACKTRACE=1`;301 /// - If you want only errors to have backtraces, set302 /// `RUST_LIB_BACKTRACE=1`;303 /// - If you want only panics to have backtraces, set `RUST_BACKTRACE=1` and304 /// `RUST_LIB_BACKTRACE=0`.305 ///306 /// [tracking]: https://github.com/rust-lang/rust/issues/53487307 #[cfg(backtrace)]308 pub fn backtrace(&self) -> &Backtrace {309 self.inner.backtrace()
492 unmodified lines
modified:src/lib.rs+11 added-2 removed
119 unmodified lines
120//! # ;121//! ```122//!123//! - A backtrace is captured and printed with the error if the underlying error124//! type does not already provide its own. In order to see backtraces, the125//! `RUST_LIB_BACKTRACE=1` environment variable must be defined.124//! type does not already provide its own. In order to see backtraces, they125//! must be enabled through the environment variables described in126//! [`std::backtrace`]:127//!128//! - If you want panics and errors to both have backtraces, set129//! `RUST_BACKTRACE=1`;130//! - If you want only errors to have backtraces, set `RUST_LIB_BACKTRACE=1`;131//! - If you want only panics to have backtraces, set `RUST_BACKTRACE=1` and132//! `RUST_LIB_BACKTRACE=0`.133//!134//! [`std::backtrace`]: https://doc.rust-lang.org/std/backtrace/index.html#environment-variables135//!136//! - Anyhow works with any error type that has an impl of `std::error::Error`,137//! including ones defined in your crate. We do not bundle a `derive(Error)`138//! macro but you can write the impls yourself or use a standalone macro like139//! [thiserror].
452 unmodified lines
modified:README.md+10 added-2 removed