mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-12-05 05:50:04 +08:00
fix: guard app setup panics during startup
This commit is contained in:
@@ -101,10 +101,14 @@ impl Logger {
|
||||
*self.sidecar_file_writer.write() = Some(sidecar_file_writer);
|
||||
|
||||
std::panic::set_hook(Box::new(move |info| {
|
||||
// Capture both common panic payload types instead of logging String payloads as unknown.
|
||||
// This global hook covers panics after logger init; early setup panics are handled separately.
|
||||
let payload = info
|
||||
.payload()
|
||||
.downcast_ref::<&str>()
|
||||
.unwrap_or(&"Unknown panic payload");
|
||||
.map(|s| (*s).to_string())
|
||||
.or_else(|| info.payload().downcast_ref::<String>().cloned())
|
||||
.unwrap_or_else(|| "Unknown panic payload".to_string());
|
||||
let location = info
|
||||
.location()
|
||||
.map(|loc| format!("{}:{}", loc.file(), loc.line()))
|
||||
|
||||
Reference in New Issue
Block a user