summaryrefslogtreecommitdiffstats
path: root/third_party/rust/error-chain/examples/has_backtrace.rs
blob: c5dac058a896ac3bdbac656246bc107012e8cfa0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//! Exits with exit code 0 if backtraces are disabled and 1 if they are enabled.
//! Used by tests to make sure backtraces are available when they should be. Should not be used
//! outside of the tests.

#[macro_use]
extern crate error_chain;

error_chain! {
    errors {
        MyError
    }
}

fn main() {
    let err = Error::from(ErrorKind::MyError);
    let has_backtrace = err.backtrace().is_some();
    ::std::process::exit(has_backtrace as i32);
}