improve reliability of panic hook by moving it to main and always creating its storage path
This commit is contained in:
+14
@@ -7,6 +7,20 @@ mod features;
|
||||
mod gui;
|
||||
mod util;
|
||||
|
||||
fn init_storage() {
|
||||
if !crate::util::consts::path::APP_STORAGE.exists() {
|
||||
std::fs::create_dir(crate::util::consts::path::APP_STORAGE.as_path()).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
fn panic_hook(panic_info: &std::panic::PanicHookInfo<'_>) {
|
||||
let backtrace = std::backtrace::Backtrace::capture();
|
||||
let message = format!("{panic_info}\nstack backtrace:\n{backtrace}\n");
|
||||
crate::util::log::log(crate::util::log::LogLevel::Panic, &message);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
init_storage();
|
||||
std::panic::set_hook(Box::new(panic_hook));
|
||||
gui::run::run();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user