This repository was archived by the owner on Aug 16, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +18
-1
lines changed Expand file tree Collapse file tree 3 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -13,5 +13,8 @@ repository = "https://github.com/brson/error-chain"
13
13
14
14
license = " MIT OR Apache-2.0"
15
15
16
+ [features ]
17
+ default = [" backtrace" ]
18
+
16
19
[dependencies ]
17
- backtrace = " 0.2.1"
20
+ backtrace = { version = " 0.2.1" , optional = true }
Original file line number Diff line number Diff line change 304
304
//! and `chain_err` invocations of compatible types. To read the
305
305
//! backtrace just call the `backtrace()` method.
306
306
//!
307
+ //! Backtrace generation can be disabled by turning off the `backtrace` feature.
308
+ //!
307
309
//! ## Iteration
308
310
//!
309
311
//! The `iter` method returns an iterator over the chain of error boxes.
310
312
//!
311
313
//! [error-type]: https://github.com/DanielKeep/rust-error-type
312
314
//! [quick-error]: https://github.com/tailhook/quick-error
313
315
316
+ #[ cfg( feature = "backtrace" ) ]
314
317
extern crate backtrace;
315
318
319
+ #[ cfg( feature = "backtrace" ) ]
316
320
pub use backtrace:: Backtrace ;
321
+ #[ cfg( not( feature = "backtrace" ) ) ]
322
+ #[ derive( Debug ) ]
323
+ pub enum Backtrace { }
317
324
318
325
mod quick_error;
319
326
@@ -689,9 +696,15 @@ impl<'a> Iterator for ErrorChainIter<'a> {
689
696
/// Returns a backtrace of the current call stack if `RUST_BACKTRACE`
690
697
/// is set to anything but ``0``, and `None` otherwise. This is used
691
698
/// in the generated error implementations.
699
+ #[ cfg( feature = "backtrace" ) ]
692
700
pub fn make_backtrace ( ) -> Option < Arc < Backtrace > > {
693
701
match std:: env:: var_os ( "RUST_BACKTRACE" ) {
694
702
Some ( ref val) if val != "0" => Some ( Arc :: new ( Backtrace :: new ( ) ) ) ,
695
703
_ => None
696
704
}
697
705
}
706
+
707
+ #[ cfg( not( feature = "backtrace" ) ) ]
708
+ pub fn make_backtrace ( ) -> Option < Arc < Backtrace > > {
709
+ None
710
+ }
Original file line number Diff line number Diff line change @@ -130,6 +130,7 @@ fn empty() {
130
130
}
131
131
132
132
#[ test]
133
+ #[ cfg( feature = "backtrace" ) ]
133
134
fn has_backtrace_depending_on_env ( ) {
134
135
use std:: env;
135
136
You can’t perform that action at this time.
0 commit comments