Add back PanicInfo to backtrace.
This commit is contained in:
committed by
Henrik Friedrichsen
parent
0a6dd20d54
commit
8a41815bb2
@@ -93,12 +93,11 @@ fn credentials_prompt(error_message: Option<String>) -> Result<Credentials, Stri
|
|||||||
authentication::create_credentials()
|
authentication::create_credentials()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn register_backtrace_panic_handler() {
|
fn register_backtrace_panic_handler() {
|
||||||
// During most of the program, Cursive is responsible for drawing to the
|
// During most of the program, Cursive is responsible for drawing to the
|
||||||
// tty. Since stdout probably doesn't work as expected during a panic, the
|
// tty. Since stdout probably doesn't work as expected during a panic, the
|
||||||
// backtrace is written to a file at $USER_CACHE_DIR/ncspot/backtrace.log.
|
// backtrace is written to a file at $USER_CACHE_DIR/ncspot/backtrace.log.
|
||||||
std::panic::set_hook(Box::new(|_panic_info| {
|
std::panic::set_hook(Box::new(|panic_info| {
|
||||||
// A panic hook will prevent the default panic handler from being
|
// A panic hook will prevent the default panic handler from being
|
||||||
// called. An unwrap in this part would cause a hard crash of ncspot.
|
// called. An unwrap in this part would cause a hard crash of ncspot.
|
||||||
// Don't unwrap/expect/panic in here!
|
// Don't unwrap/expect/panic in here!
|
||||||
@@ -107,6 +106,7 @@ fn register_backtrace_panic_handler() {
|
|||||||
path.push("backtrace.log");
|
path.push("backtrace.log");
|
||||||
if let Ok(mut file) = File::create(path) {
|
if let Ok(mut file) = File::create(path) {
|
||||||
writeln!(file, "{}", backtrace::Backtrace::force_capture()).unwrap_or_default();
|
writeln!(file, "{}", backtrace::Backtrace::force_capture()).unwrap_or_default();
|
||||||
|
writeln!(file, "{}", panic_info).unwrap_or_default();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|||||||
Reference in New Issue
Block a user