diff --git a/crates/agent/src/db.rs b/crates/agent/src/db.rs index 7d69e03c325..a09aa9c2c13 100644 --- a/crates/agent/src/db.rs +++ b/crates/agent/src/db.rs @@ -2,7 +2,7 @@ use crate::{AgentMessage, AgentMessageContent, UserMessage, UserMessageContent}; use acp_thread::ClientUserMessageId; use agent_client_protocol::schema::v1 as acp; use agent_settings::AgentProfileId; -use anyhow::{Result, anyhow}; +use anyhow::Result; use chrono::{DateTime, Utc}; use collections::{HashMap, IndexMap}; use futures::{FutureExt, future::Shared}; @@ -444,7 +444,7 @@ impl ThreadsDatabase { data BLOB NOT NULL ) "})?() - .map_err(|e| anyhow!("Failed to create threads table: {}", e))?; + .map_err(|e| e.context("Failed to create threads table"))?; if let Ok(mut s) = connection.exec(indoc! {" ALTER TABLE threads ADD COLUMN parent_id TEXT diff --git a/crates/keymap_editor/src/keymap_editor.rs b/crates/keymap_editor/src/keymap_editor.rs index aecaea7fcba..db405135994 100644 --- a/crates/keymap_editor/src/keymap_editor.rs +++ b/crates/keymap_editor/src/keymap_editor.rs @@ -3668,7 +3668,7 @@ async fn save_keybinding_update( keyboard_mapper, deprecated_aliases, ) - .map_err(|err| anyhow::anyhow!("Could not save updated keybinding: {}", err))?; + .map_err(|err| err.context("Could not save updated keybinding"))?; fs.write( paths::keymap_file().as_path(), updated_keymap_contents.as_bytes(), diff --git a/crates/remote/src/transport/ssh.rs b/crates/remote/src/transport/ssh.rs index 25946c0b7c0..f897bdd1d96 100644 --- a/crates/remote/src/transport/ssh.rs +++ b/crates/remote/src/transport/ssh.rs @@ -496,7 +496,9 @@ impl RemoteConnection for SshRemoteConnection { { Ok(process) => process, Err(error) => { - return Task::ready(Err(anyhow!("failed to spawn remote server: {}", error))); + return Task::ready(Err( + anyhow::Error::new(error).context("failed to spawn remote server") + )); } }; diff --git a/crates/remote/src/transport/wsl.rs b/crates/remote/src/transport/wsl.rs index 21ebdcbd049..9b8e7763944 100644 --- a/crates/remote/src/transport/wsl.rs +++ b/crates/remote/src/transport/wsl.rs @@ -210,7 +210,7 @@ impl WslRemoteConnection { let mkdir = self.shell_kind.prepend_command_prefix("mkdir"); self.run_wsl_command(&mkdir, &["-p", &parent]) .await - .map_err(|e| anyhow!("Failed to create directory: {}", e))?; + .map_err(|e| e.context("Failed to create directory"))?; } let binary_exists_on_server = self @@ -346,7 +346,7 @@ impl WslRemoteConnection { self.run_wsl_command("sh", &["-c", &script]) .await - .map_err(|e| anyhow!("Failed to extract server binary: {}", e))?; + .map_err(|e| e.context("Failed to extract server binary"))?; Ok(()) } } @@ -395,7 +395,9 @@ impl RemoteConnection for WslRemoteConnection { { Ok(process) => process, Err(error) => { - return Task::ready(Err(anyhow!("failed to spawn remote server: {}", error))); + return Task::ready(Err( + anyhow::Error::new(error).context("failed to spawn remote server") + )); } };