Debian Codegraph @

third_party/rust/error-chain/examples/has_backtrace.rs

raw
1 //! Exits with exit code 0 if backtraces are disabled and 1 if they are enabled.
2 //! Used by tests to make sure backtraces are available when they should be. Should not be used
3 //! outside of the tests.
4
5 #[macro_use]
6 extern crate error_chain;
7
8 error_chain! {
9 errors {
10 MyError
11 }
12 }
13
14 fn main() {
15 let err = Error::from(ErrorKind::MyError);
16 let has_backtrace = err.backtrace().is_some();
17 ::std::process::exit(has_backtrace as i32);
18 }