Use string interpolation (#13482)

Release Notes:

- N/A

---------

Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
This commit is contained in:
Hamir Mahal 2024-06-25 07:57:50 -07:00 committed by GitHub
parent 2dee4f87fd
commit f40d2313fb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 12 additions and 15 deletions

View file

@ -56,11 +56,11 @@ use crate::zed::inline_completion_registry;
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
fn fail_to_launch(e: anyhow::Error) { fn fail_to_launch(e: anyhow::Error) {
eprintln!("Zed failed to launch: {:?}", e); eprintln!("Zed failed to launch: {e:?}");
App::new().run(move |cx| { App::new().run(move |cx| {
if let Ok(window) = cx.open_window(gpui::WindowOptions::default(), |cx| cx.new_view(|_| gpui::Empty)) { if let Ok(window) = cx.open_window(gpui::WindowOptions::default(), |cx| cx.new_view(|_| gpui::Empty)) {
window.update(cx, |_, cx| { window.update(cx, |_, cx| {
let response = cx.prompt(gpui::PromptLevel::Critical, "Zed failed to launch", Some(&format!("{}\n\nFor help resolving this, please open an issue on https://github.com/zed-industries/zed", e)), &["Exit"]); let response = cx.prompt(gpui::PromptLevel::Critical, "Zed failed to launch", Some(&format!("{e}\n\nFor help resolving this, please open an issue on https://github.com/zed-industries/zed")), &["Exit"]);
cx.spawn(|_, mut cx| async move { cx.spawn(|_, mut cx| async move {
response.await?; response.await?;
@ -80,7 +80,7 @@ fn fail_to_open_window_async(e: anyhow::Error, cx: &mut AsyncAppContext) {
} }
fn fail_to_open_window(e: anyhow::Error, _cx: &mut AppContext) { fn fail_to_open_window(e: anyhow::Error, _cx: &mut AppContext) {
eprintln!("Zed failed to open a window: {:?}", e); eprintln!("Zed failed to open a window: {e:?}");
#[cfg(not(target_os = "linux"))] #[cfg(not(target_os = "linux"))]
{ {
process::exit(1); process::exit(1);
@ -99,7 +99,7 @@ fn fail_to_open_window(e: anyhow::Error, _cx: &mut AppContext) {
.add_notification( .add_notification(
notification_id, notification_id,
Notification::new("Zed failed to launch") Notification::new("Zed failed to launch")
.body(Some(format!("{:?}", e).as_str())) .body(Some(format!("{e:?}").as_str()))
.priority(Priority::High) .priority(Priority::High)
.icon(ashpd::desktop::Icon::with_names(&[ .icon(ashpd::desktop::Icon::with_names(&[
"dialog-question-symbolic", "dialog-question-symbolic",
@ -751,7 +751,7 @@ fn init_stdout_logger() {
)?; )?;
write!(buf, "{:<5}", buf.default_styled_level(record.level()))?; write!(buf, "{:<5}", buf.default_styled_level(record.level()))?;
if let Some(path) = record.module_path() { if let Some(path) = record.module_path() {
write!(buf, " {}", path)?; write!(buf, " {path}")?;
} }
write!(buf, "{}", subtle.value("]"))?; write!(buf, "{}", subtle.value("]"))?;
writeln!(buf, " {}", record.args()) writeln!(buf, " {}", record.args())

View file

@ -113,14 +113,14 @@ pub fn init_panic_hook(
if !is_pty { if !is_pty {
if let Some(panic_data_json) = serde_json::to_string(&panic_data).log_err() { if let Some(panic_data_json) = serde_json::to_string(&panic_data).log_err() {
let timestamp = chrono::Utc::now().format("%Y_%m_%d %H_%M_%S").to_string(); let timestamp = chrono::Utc::now().format("%Y_%m_%d %H_%M_%S").to_string();
let panic_file_path = paths::logs_dir().join(format!("zed-{}.panic", timestamp)); let panic_file_path = paths::logs_dir().join(format!("zed-{timestamp}.panic"));
let panic_file = std::fs::OpenOptions::new() let panic_file = std::fs::OpenOptions::new()
.append(true) .append(true)
.create(true) .create(true)
.open(&panic_file_path) .open(&panic_file_path)
.log_err(); .log_err();
if let Some(mut panic_file) = panic_file { if let Some(mut panic_file) = panic_file {
writeln!(&mut panic_file, "{}", panic_data_json).log_err(); writeln!(&mut panic_file, "{panic_data_json}").log_err();
panic_file.flush().log_err(); panic_file.flush().log_err();
} }
} }
@ -494,7 +494,7 @@ async fn upload_previous_crashes(
if let Some((panicked_on, payload)) = most_recent_panic.as_ref() { if let Some((panicked_on, payload)) = most_recent_panic.as_ref() {
request = request request = request
.header("x-zed-panicked-on", format!("{}", panicked_on)) .header("x-zed-panicked-on", format!("{panicked_on}"))
.header("x-zed-panic", payload) .header("x-zed-panic", payload)
} }
if let Some(installation_id) = installation_id.as_ref() { if let Some(installation_id) = installation_id.as_ref() {

View file

@ -247,7 +247,7 @@ pub async fn handle_cli_connection(
Err(error) => { Err(error) => {
responses responses
.send(CliResponse::Stderr { .send(CliResponse::Stderr {
message: format!("{}", error), message: format!("{error}"),
}) })
.log_err(); .log_err();
responses.send(CliResponse::Exit { status: 1 }).log_err(); responses.send(CliResponse::Exit { status: 1 }).log_err();
@ -263,7 +263,7 @@ pub async fn handle_cli_connection(
{ {
responses responses
.send(CliResponse::Stderr { .send(CliResponse::Stderr {
message: format!("{}", e), message: format!("{e}"),
}) })
.log_err(); .log_err();
responses.send(CliResponse::Exit { status: 1 }).log_err(); responses.send(CliResponse::Exit { status: 1 }).log_err();
@ -342,10 +342,7 @@ pub async fn handle_cli_connection(
Some(Err(err)) => { Some(Err(err)) => {
responses responses
.send(CliResponse::Stderr { .send(CliResponse::Stderr {
message: format!( message: format!("error opening {path:?}: {err}"),
"error opening {:?}: {}",
path, err
),
}) })
.log_err(); .log_err();
errored = true; errored = true;
@ -392,7 +389,7 @@ pub async fn handle_cli_connection(
errored = true; errored = true;
responses responses
.send(CliResponse::Stderr { .send(CliResponse::Stderr {
message: format!("error opening {:?}: {}", paths, error), message: format!("error opening {paths:?}: {error}"),
}) })
.log_err(); .log_err();
} }