build: remove panic message dependency
This commit is contained in:
parent
b91605864d
commit
609d7ceb7a
3 changed files with 15 additions and 9 deletions
7
Cargo.lock
generated
7
Cargo.lock
generated
|
@ -3847,7 +3847,6 @@ dependencies = [
|
||||||
"nokhwa",
|
"nokhwa",
|
||||||
"openpnp_capture_sys",
|
"openpnp_capture_sys",
|
||||||
"openssl-sys",
|
"openssl-sys",
|
||||||
"panic-message",
|
|
||||||
"parking_lot 0.12.3",
|
"parking_lot 0.12.3",
|
||||||
"qrcode",
|
"qrcode",
|
||||||
"qrcodegen",
|
"qrcodegen",
|
||||||
|
@ -6587,12 +6586,6 @@ dependencies = [
|
||||||
"sha2 0.10.8",
|
"sha2 0.10.8",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "panic-message"
|
|
||||||
version = "0.3.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "384e52fd8fbd4cbe3c317e8216260c21a0f9134de108cea8a4dd4e7e152c472d"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "parking"
|
name = "parking"
|
||||||
version = "2.2.0"
|
version = "2.2.0"
|
||||||
|
|
|
@ -52,7 +52,6 @@ rust-i18n = "2.3.1"
|
||||||
|
|
||||||
## other
|
## other
|
||||||
backtrace = "0.3"
|
backtrace = "0.3"
|
||||||
panic-message = "0.3.0"
|
|
||||||
thiserror = "1.0.58"
|
thiserror = "1.0.58"
|
||||||
futures = "0.3"
|
futures = "0.3"
|
||||||
dirs = "5.0.1"
|
dirs = "5.0.1"
|
||||||
|
|
16
src/main.rs
16
src/main.rs
|
@ -48,7 +48,7 @@ fn real_main() {
|
||||||
let time = grim::gui::views::View::format_time(chrono::Utc::now().timestamp());
|
let time = grim::gui::views::View::format_time(chrono::Utc::now().timestamp());
|
||||||
let target = egui::os::OperatingSystem::from_target_os();
|
let target = egui::os::OperatingSystem::from_target_os();
|
||||||
let ver = grim::VERSION;
|
let ver = grim::VERSION;
|
||||||
let msg = panic_message::panic_info_message(info);
|
let msg = panic_info_message(info);
|
||||||
let err = format!("{} - {:?} - v{}\n\n{}\n\n{:?}", time, target, ver, msg, backtrace);
|
let err = format!("{} - {:?} - v{}\n\n{}\n\n{:?}", time, target, ver, msg, backtrace);
|
||||||
// Save backtrace to file.
|
// Save backtrace to file.
|
||||||
let log = grim::Settings::crash_report_path();
|
let log = grim::Settings::crash_report_path();
|
||||||
|
@ -76,6 +76,20 @@ fn real_main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get panic message from crash payload.
|
||||||
|
fn panic_info_message<'pi>(panic_info: &'pi std::panic::PanicInfo<'_>) -> &'pi str {
|
||||||
|
let payload = panic_info.payload();
|
||||||
|
// taken from: https://github.com/rust-lang/rust/blob/4b9f4b221b92193c7e95b1beb502c6eb32c3b613/library/std/src/panicking.rs#L194-L200
|
||||||
|
match payload.downcast_ref::<&'static str>() {
|
||||||
|
Some(msg) => *msg,
|
||||||
|
None => match payload.downcast_ref::<String>() {
|
||||||
|
Some(msg) => msg.as_str(),
|
||||||
|
// Copy what rustc does in the default panic handler
|
||||||
|
None => "Box<dyn Any>",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Start GUI with Desktop related setup passing data from opening.
|
/// Start GUI with Desktop related setup passing data from opening.
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[cfg(not(target_os = "android"))]
|
#[cfg(not(target_os = "android"))]
|
||||||
|
|
Loading…
Reference in a new issue