Skip to content

Commit

Permalink
[rust] Enable using RUST_BACKTRACE to capture backtrace as well
Browse files Browse the repository at this point in the history
  • Loading branch information
bonigarcia committed Oct 3, 2023
1 parent ff31b8f commit d9405de
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions rust/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ fn main() {
let cache_path =
StringKey(vec![CACHE_PATH_KEY], &cli.cache_path.unwrap_or_default()).get_value();

let debug = cli.debug || BooleanKey("debug", false).get_value();
let trace = cli.trace || BooleanKey("trace", false).get_value();
let backtrace = cli.backtrace || BooleanKey("backtrace", false).get_value();
let debug = backtrace || cli.debug || BooleanKey("debug", false).get_value();
let trace = cli.trace || BooleanKey("trace", false).get_value();
let log = Logger::create(&cli.output, debug, trace);
let grid = cli.grid;
let mut browser_name: String = cli.browser.unwrap_or_default();
Expand Down Expand Up @@ -261,10 +261,11 @@ fn log_driver_and_browser_path(
}

fn flush_and_exit(code: i32, log: &Logger, is_backtrace: bool, err: Option<Error>) -> ! {
if err.is_some() && is_backtrace {
let backtrace = Backtrace::force_capture();
if err.is_some() {
let mut backtrace = Backtrace::capture();
let backtrace_status = backtrace.status();
if backtrace_status == BacktraceStatus::Captured {
if is_backtrace || backtrace_status == BacktraceStatus::Captured {
backtrace = Backtrace::force_capture();
log.debug(format!("Backtrace:\n{}", backtrace));
}
}
Expand Down

0 comments on commit d9405de

Please sign in to comment.