mirror of
https://github.com/gitui-org/gitui
synced 2026-05-23 08:58:21 +00:00
Addresses TODO with macro log_eprintln!
This commit is contained in:
parent
5906a2789d
commit
f2b2665c78
1 changed files with 10 additions and 6 deletions
16
src/main.rs
16
src/main.rs
|
|
@ -327,13 +327,19 @@ fn start_terminal<W: Write>(
|
|||
Ok(terminal)
|
||||
}
|
||||
|
||||
// do log::error! and eprintln! in one line, pass sting, error and backtrace
|
||||
macro_rules! log_eprintln {
|
||||
($string:expr, $e:expr, $bt:expr) => {
|
||||
log::error!($string, $e, $bt);
|
||||
eprintln!($string, $e, $bt);
|
||||
};
|
||||
}
|
||||
|
||||
fn set_panic_handlers() -> Result<()> {
|
||||
// regular panic handler
|
||||
panic::set_hook(Box::new(|e| {
|
||||
let backtrace = Backtrace::new();
|
||||
//TODO: create macro to do both in one
|
||||
log::error!("panic: {:?}\ntrace:\n{:?}", e, backtrace);
|
||||
eprintln!("panic: {:?}\ntrace:\n{:?}", e, backtrace);
|
||||
log_eprintln!("panic: {:?}\ntrace:\n{:?}", e, backtrace);
|
||||
shutdown_terminal();
|
||||
}));
|
||||
|
||||
|
|
@ -341,9 +347,7 @@ fn set_panic_handlers() -> Result<()> {
|
|||
rayon_core::ThreadPoolBuilder::new()
|
||||
.panic_handler(|e| {
|
||||
let backtrace = Backtrace::new();
|
||||
//TODO: create macro to do both in one
|
||||
log::error!("panic: {:?}\ntrace:\n{:?}", e, backtrace);
|
||||
eprintln!("panic: {:?}\ntrace:\n{:?}", e, backtrace);
|
||||
log_eprintln!("panic: {:?}\ntrace:\n{:?}", e, backtrace);
|
||||
shutdown_terminal();
|
||||
process::abort();
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in a new issue