diff --git a/src/main.rs b/src/main.rs index 379eb89b..e2f47377 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,6 @@ -#![feature(error_generic_member_access, provide_any)] +#![feature(error_reporter)] #![recursion_limit = "256"] -use std::backtrace::Backtrace; use std::convert::TryInto; use std::env; use std::panic; @@ -159,29 +158,10 @@ fn init_proxy() -> Option { } fn print_error(err: E) { - eprintln!("Error: {}", err); - - let mut err: &dyn std::error::Error = &err; - let mut deepest_backtrace = err.request_ref::(); - if let Some(e) = err.source() { - eprintln!("\nCaused by:"); - let multiple = e.source().is_some(); - let mut line_counter = 0..; - while let (Some(e), Some(line)) = (err.source(), line_counter.next()) { - if multiple { - eprint!("{: >4}: ", line) - } else { - eprint!(" ") - }; - eprintln!("{}", e); - if let Some(backtrace) = e.request_ref::() { - deepest_backtrace = Some(backtrace); - } - err = e; - } - } - - if let Some(backtrace) = deepest_backtrace { - eprintln!("\nBacktrace:\n{}", backtrace); - } + eprintln!( + "Error: {}", + std::error::Report::new(err) + .pretty(true) + .show_backtrace(true) + ); }