From 6c58d715be02b015f143ff70a3bac1291e3b8e16 Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Tue, 1 Aug 2023 13:26:03 +0200 Subject: [PATCH] feat: added `human_panic` crate for better panics handling --- Cargo.lock | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++- Cargo.toml | 4 ++ src/main.rs | 9 +++-- 3 files changed, 120 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fa0042c..44fda3f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -72,6 +72,7 @@ dependencies = [ "fluent-templates", "glib-build-tools", "gtk4", + "human-panic", "lazy_static", "libadwaita", "md-5", @@ -103,6 +104,55 @@ dependencies = [ "wincompatlib", ] +[[package]] +name = "anstream" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is-terminal", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a30da5c5f2d5e72842e00bcb57657162cdabef0931f40e2deb9b4140440cecd" + +[[package]] +name = "anstyle-parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "938874ff5980b03a87c5524b3ae5b59cf99b1d6bc836848df7bc5ada9643c333" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "anstyle-wincon" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188" +dependencies = [ + "anstyle", + "windows-sys", +] + [[package]] name = "anyhow" version = "1.0.72" @@ -525,6 +575,12 @@ dependencies = [ "inout", ] +[[package]] +name = "colorchoice" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" + [[package]] name = "concurrent-queue" version = "2.2.0" @@ -699,7 +755,7 @@ dependencies = [ "serde", "serde_derive", "serde_json", - "uuid", + "uuid 0.8.2", ] [[package]] @@ -1446,6 +1502,22 @@ dependencies = [ "digest", ] +[[package]] +name = "human-panic" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38a841f87949b0dd751864e769a870be79dc34abcee1cf31d737a61d498b22b6" +dependencies = [ + "anstream", + "anstyle", + "backtrace", + "os_info", + "serde", + "serde_derive", + "toml", + "uuid 1.4.1", +] + [[package]] name = "ident_case" version = "1.0.1" @@ -1546,6 +1618,17 @@ dependencies = [ "once_cell", ] +[[package]] +name = "is-terminal" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" +dependencies = [ + "hermit-abi", + "rustix 0.38.4", + "windows-sys", +] + [[package]] name = "is-wsl" version = "0.4.0" @@ -1912,6 +1995,17 @@ dependencies = [ "pin-project-lite", ] +[[package]] +name = "os_info" +version = "3.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "006e42d5b888366f1880eda20371fedde764ed2213dc8496f49622fa0c99cd5e" +dependencies = [ + "log", + "serde", + "winapi", +] + [[package]] name = "overload" version = "0.1.1" @@ -3034,6 +3128,12 @@ version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" +[[package]] +name = "utf8parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" + [[package]] name = "uuid" version = "0.8.2" @@ -3043,6 +3143,15 @@ dependencies = [ "getrandom", ] +[[package]] +name = "uuid" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79daa5ed5740825c40b389c5e50312b9c86df53fccd33f281df655642b43869d" +dependencies = [ + "getrandom", +] + [[package]] name = "valuable" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index b6e2153..45f9d8b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,6 +3,8 @@ name = "anime-game-launcher" version = "3.7.6" description = "Anime Game launcher" authors = ["Nikita Podvirnyy "] +homepage = "https://github.com/an-anime-team/an-anime-game-launcher" +repository = "https://github.com/an-anime-team/an-anime-game-launcher" license = "GPL-3.0" edition = "2021" build = "build.rs" @@ -42,3 +44,5 @@ tracing-subscriber = "0.3" fluent-templates = "0.8" unic-langid = "0.9" + +human-panic = "1.1.5" diff --git a/src/main.rs b/src/main.rs index 3a2fd56..748e8fa 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,6 @@ +use std::path::PathBuf; +use std::sync::atomic::{AtomicBool, Ordering}; + use relm4::prelude::*; use anime_launcher_sdk::config::ConfigExt; @@ -12,9 +15,6 @@ use anime_launcher_sdk::anime_game_core::genshin::prelude::*; use tracing_subscriber::prelude::*; use tracing_subscriber::filter::*; -use std::path::PathBuf; -use std::sync::atomic::{AtomicBool, Ordering}; - pub mod move_folder; pub mod i18n; pub mod background; @@ -70,6 +70,9 @@ lazy_static::lazy_static! { } fn main() { + // Setup custom panic handler + human_panic::setup_panic!(human_panic::metadata!()); + // Create launcher folder if it isn't if !LAUNCHER_FOLDER.exists() { std::fs::create_dir_all(LAUNCHER_FOLDER.as_path()).expect("Failed to create launcher folder");