fix: log actual panic message when MCP startup fails
All checks were successful
Build & Sign Wraith / Build Windows + Sign (push) Successful in 2m54s

Was logging "panicked — continuing" without the WHY. Now captures
the panic payload (String, &str, or type_id) so the log shows
exactly what went wrong in clone_services().

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Vantz Stockwell 2026-03-25 11:06:06 -04:00
parent 03bb6f3ccf
commit 5d1aeb5fe3

View File

@ -134,9 +134,10 @@ pub fn run() {
let log_file = data_directory().join("wraith.log");
let _ = write_log(&log_file, "Setup: starting MCP and error watcher");
if let Ok(state) = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
match std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
app.state::<AppState>().inner().clone_services()
})) {
Ok(state) => {
let (ssh, rdp, sftp, scrollback, watcher) = state;
let _ = write_log(&log_file, "Setup: cloned services OK");
@ -151,8 +152,17 @@ pub fn run() {
Err(e) => { let _ = write_log(&log_file2, &format!("MCP server FAILED: {}", e)); }
}
});
}
Err(panic) => {
let msg = if let Some(s) = panic.downcast_ref::<String>() {
s.clone()
} else if let Some(s) = panic.downcast_ref::<&str>() {
s.to_string()
} else {
let _ = write_log(&log_file, "MCP startup panicked — continuing without MCP");
format!("{:?}", panic.type_id())
};
let _ = write_log(&log_file, &format!("MCP startup panicked: {}", msg));
}
}
}