diff --git a/crates/project/src/project.rs b/crates/project/src/project.rs index 21d64fe91f..3802039a81 100644 --- a/crates/project/src/project.rs +++ b/crates/project/src/project.rs @@ -1661,14 +1661,15 @@ impl Project { path: impl Into, cx: &mut ModelContext, ) -> Task> { - let task = self.open_buffer(path, cx); + let project_path = path.into(); + let task = self.open_buffer(project_path.clone(), cx); cx.spawn_weak(|_, cx| async move { let buffer = task.await?; let project_entry_id = buffer .read_with(&cx, |buffer, cx| { File::from_dyn(buffer.file()).and_then(|file| file.project_entry_id(cx)) }) - .ok_or_else(|| anyhow!("no project entry"))?; + .with_context(|| format!("no project entry for {project_path:?}"))?; let buffer: &AnyModelHandle = &buffer; Ok((project_entry_id, buffer.clone())) diff --git a/crates/project2/src/project2.rs b/crates/project2/src/project2.rs index 12940dd2c4..9750fe053d 100644 --- a/crates/project2/src/project2.rs +++ b/crates/project2/src/project2.rs @@ -1691,14 +1691,15 @@ impl Project { path: impl Into, cx: &mut ModelContext, ) -> Task> { - let task = self.open_buffer(path, cx); + let project_path = path.into(); + let task = self.open_buffer(project_path.clone(), cx); cx.spawn(move |_, mut cx| async move { let buffer = task.await?; let project_entry_id = buffer .update(&mut cx, |buffer, cx| { File::from_dyn(buffer.file()).and_then(|file| file.project_entry_id(cx)) })? - .ok_or_else(|| anyhow!("no project entry"))?; + .with_context(|| format!("no project entry for {project_path:?}"))?; let buffer: &AnyModel = &buffer; Ok((project_entry_id, buffer.clone()))