Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Add additional panic information to panic events
Joseph Lyonscc055901e1b5
diff --git a/crates/feedback/src/system_specs.rs b/crates/feedback/src/system_specs.rsindex b6eb6e8b6d0..48955a86291 100644--- a/crates/feedback/src/system_specs.rs+++ b/crates/feedback/src/system_specs.rs@@ -6,6 +6,8 @@ use std::{env, fmt::Display};use sysinfo::{System, SystemExt};use util::channel::ReleaseChannel;+// TODO: Move this file out of feedback and into a more general place+#[derive(Clone, Debug, Serialize)]pub struct SystemSpecs {#[serde(serialize_with = "serialize_app_version")]diff --git a/crates/zed/src/main.rs b/crates/zed/src/main.rsindex 9ec3e3d3f6b..4b0661c6e62 100644--- a/crates/zed/src/main.rs+++ b/crates/zed/src/main.rs@@ -70,10 +70,7 @@ fn main() {log::info!("========== starting zed ==========");let mut app = gpui::App::new(Assets).unwrap();- let app_version = ZED_APP_VERSION- .or_else(|| app.platform().app_version().ok())- .map_or("dev".to_string(), |v| v.to_string());- init_panic_hook(app_version);+ init_panic_hook(&app);app.background();@@ -376,19 +373,29 @@ struct Panic {backtrace: Vec<String>,// TODO// stripped_backtrace: String,+ release_channel: String,+ os_name: String,+ os_version: Option<String>,+ architecture: String,time: u128,}#[derive(Serialize)]struct PanicRequest {panic: Panic,+ // TODO: Move to Panic struct, as app_version - requires changing zed.devversion: String,token: String,}-fn init_panic_hook(app_version: String) {+fn init_panic_hook(app: &App) {let is_pty = stdout_is_a_pty();+ let platform = app.platform();+panic::set_hook(Box::new(move |info| {+ let app_version = ZED_APP_VERSION+ .or_else(|| platform.app_version().ok())+ .map_or("dev".to_string(), |v| v.to_string());let backtrace = Backtrace::new();let thread = thread::current();@@ -414,6 +421,13 @@ fn init_panic_hook(app_version: String) {.map(|line| line.to_string()).collect(),// modified_backtrace: None,+ release_channel: RELEASE_CHANNEL.dev_name().into(),+ os_name: platform.os_name().into(),+ os_version: platform+ .os_version()+ .ok()+ .map(|os_version| os_version.to_string()),+ architecture: env::consts::ARCH.into(),time: SystemTime::now().duration_since(UNIX_EPOCH).unwrap()