diff --git a/crates/editor/src/items.rs b/crates/editor/src/items.rs index 708efbbe979dd153dbafde265e56bc2ddd725f76..f8e8f1c3750f8c612febc6b8a08b3106a2efaed0 100644 --- a/crates/editor/src/items.rs +++ b/crates/editor/src/items.rs @@ -1079,12 +1079,17 @@ impl SerializableItem for Editor { } } Ok(None) => { - return Task::ready(Err(anyhow!("No path or contents found for buffer"))); + return Task::ready(Err(anyhow!( + "Unable to deserialize editor: No entry in database for item_id: {item_id} and workspace_id {workspace_id:?}" + ))); } Err(error) => { return Task::ready(Err(error)); } }; + log::debug!( + "Deserialized editor {item_id:?} in workspace {workspace_id:?}, {serialized_editor:?}" + ); match serialized_editor { SerializedEditor { @@ -1112,7 +1117,8 @@ impl SerializableItem for Editor { // First create the empty buffer let buffer = project .update(cx, |project, cx| project.create_buffer(true, cx))? - .await?; + .await + .context("Failed to create buffer while deserializing editor")?; // Then set the text so that the dirty bit is set correctly buffer.update(cx, |buffer, cx| { @@ -1154,7 +1160,9 @@ impl SerializableItem for Editor { match opened_buffer { Some(opened_buffer) => { window.spawn(cx, async move |cx| { - let (_, buffer) = opened_buffer.await?; + let (_, buffer) = opened_buffer + .await + .context("Failed to open path in project")?; // This is a bit wasteful: we're loading the whole buffer from // disk and then overwrite the content. @@ -1220,7 +1228,8 @@ impl SerializableItem for Editor { } => window.spawn(cx, async move |cx| { let buffer = project .update(cx, |project, cx| project.create_buffer(true, cx))? - .await?; + .await + .context("Failed to create buffer")?; cx.update(|window, cx| { cx.new(|cx| { diff --git a/crates/project/src/buffer_store.rs b/crates/project/src/buffer_store.rs index b36b44cfd4d0b3f73e808becf5168cd47f7e4c06..51bca611f4b69546cc358cb59724dbb7f98d219e 100644 --- a/crates/project/src/buffer_store.rs +++ b/crates/project/src/buffer_store.rs @@ -24,7 +24,7 @@ use rpc::{ use std::{io, sync::Arc, time::Instant}; use text::{BufferId, ReplicaId}; -use util::{ResultExt as _, TryFutureExt, debug_panic, maybe, rel_path::RelPath}; +use util::{ResultExt as _, TryFutureExt, debug_panic, maybe, paths::PathStyle, rel_path::RelPath}; use worktree::{File, PathChange, ProjectEntryId, Worktree, WorktreeId}; /// A set of open buffers. @@ -621,8 +621,11 @@ impl LocalBufferStore { let load_file = worktree.load_file(path.as_ref(), cx); let reservation = cx.reserve_entity(); let buffer_id = BufferId::from(reservation.entity_id().as_non_zero_u64()); + let path = path.clone(); cx.spawn(async move |_, cx| { - let loaded = load_file.await?; + let loaded = load_file.await.with_context(|| { + format!("Could not open path: {}", path.display(PathStyle::local())) + })?; let text_buffer = cx .background_spawn(async move { text::Buffer::new(ReplicaId::LOCAL, buffer_id, loaded.text) diff --git a/crates/workspace/src/persistence/model.rs b/crates/workspace/src/persistence/model.rs index 08a2f2e38dd142848f8a9c07652e147b58bee233..a37b2ebbe93efb23cad6a98f127ba1f8800a3eb3 100644 --- a/crates/workspace/src/persistence/model.rs +++ b/crates/workspace/src/persistence/model.rs @@ -3,7 +3,7 @@ use crate::{ Member, Pane, PaneAxis, SerializableItemRegistry, Workspace, WorkspaceId, item::ItemHandle, path_list::PathList, }; -use anyhow::Result; +use anyhow::{Context, Result}; use async_recursion::async_recursion; use collections::IndexSet; use db::sqlez::{ @@ -220,6 +220,7 @@ impl SerializedPaneGroup { let new_items = serialized_pane .deserialize_to(project, &pane, workspace_id, workspace.clone(), cx) .await + .context("Could not deserialize pane)") .log_err()?; if pane diff --git a/crates/worktree/src/worktree.rs b/crates/worktree/src/worktree.rs index f889fb3b8218b18983c4509b653cf0e0ce863fcd..5f8253e2dfb48fa6882dabf49c64073023a2a298 100644 --- a/crates/worktree/src/worktree.rs +++ b/crates/worktree/src/worktree.rs @@ -1706,9 +1706,9 @@ impl LocalWorktree { refresh.recv().await; log::trace!("refreshed entry {path:?} in {:?}", t0.elapsed()); let new_entry = this.read_with(cx, |this, _| { - this.entry_for_path(&path) - .cloned() - .context("reading path after update") + this.entry_for_path(&path).cloned().with_context(|| { + format!("Could not find entry in worktree for {path:?} after refresh") + }) })??; Ok(Some(new_entry)) })