Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Improve error messages on extension loading (#42266)

liuyanghejerry10d5d78dedce
diff --git a/crates/extension/src/extension_manifest.rs b/crates/extension/src/extension_manifest.rs
index 7e074ffcab7..7a15a3c58b7 100644
--- a/crates/extension/src/extension_manifest.rs
+++ b/crates/extension/src/extension_manifest.rs
@@ -267,10 +267,9 @@ impl ExtensionManifest {
let mut extension_manifest_path = extension_dir.join("extension.json");
if fs.is_file(&extension_manifest_path).await {
- let manifest_content = fs
- .load(&extension_manifest_path)
- .await
- .with_context(|| format!("failed to load {extension_name} extension.json"))?;
+ let manifest_content = fs.load(&extension_manifest_path).await.with_context(|| {
+ format!("loading {extension_name} extension.json, {extension_manifest_path:?}")
+ })?;
let manifest_json = serde_json::from_str::<OldExtensionManifest>(&manifest_content)
.with_context(|| {
format!("invalid extension.json for extension {extension_name}")
@@ -279,10 +278,9 @@ impl ExtensionManifest {
Ok(manifest_from_old_manifest(manifest_json, extension_name))
} else {
extension_manifest_path.set_extension("toml");
- let manifest_content = fs
- .load(&extension_manifest_path)
- .await
- .with_context(|| format!("failed to load {extension_name} extension.toml"))?;
+ let manifest_content = fs.load(&extension_manifest_path).await.with_context(|| {
+ format!("loading {extension_name} extension.toml, {extension_manifest_path:?}")
+ })?;
toml::from_str(&manifest_content).map_err(|err| {
anyhow!("Invalid extension.toml for extension {extension_name}:\n{err}")
})
diff --git a/crates/extension_host/src/wasm_host.rs b/crates/extension_host/src/wasm_host.rs
index eb26c44f205..1e4bed7a50b 100644
--- a/crates/extension_host/src/wasm_host.rs
+++ b/crates/extension_host/src/wasm_host.rs
@@ -763,17 +763,17 @@ impl WasmExtension {
.fs
.open_sync(&path)
.await
- .context("failed to open wasm file")?;
+ .context(format!("opening wasm file, path: {path:?}"))?;
let mut wasm_bytes = Vec::new();
wasm_file
.read_to_end(&mut wasm_bytes)
- .context("failed to read wasm")?;
+ .context(format!("reading wasm file, path: {path:?}"))?;
wasm_host
.load_extension(wasm_bytes, manifest, cx)
.await
- .with_context(|| format!("failed to load wasm extension {}", manifest.id))
+ .with_context(|| format!("loading wasm extension: {}", manifest.id))
}
pub async fn call<T, Fn>(&self, f: Fn) -> Result<T>