Skip to content

Offline, privacy-first grammar checker. Fast, open-source, Rust-powered

fix(ls): improve error handling for #251

Elijah Potterf70f289842e1
diff --git a/harper-ls/src/backend.rs b/harper-ls/src/backend.rs
index 026f0d998..85e2d9f78 100644
--- a/harper-ls/src/backend.rs
+++ b/harper-ls/src/backend.rs
@@ -54,7 +54,7 @@ impl Backend {
fn file_dict_name(url: &Url) -> Option<PathBuf> {
let mut rewritten = String::new();
- // We assume all URLs are local files and have a base
+ // We assume all URLs are local files and have a base.
for seg in url.to_file_path().ok()?.components() {
if !matches!(seg, Component::RootDir) {
rewritten.push_str(&seg.as_os_str().to_string_lossy());
@@ -120,7 +120,7 @@ impl Backend {
);
let Some(file_dictionary) = file_dictionary else {
- return Err(anyhow!("Unable to compute dictionary path."));
+ return Err(anyhow!("Unable to compute dictionary path for {url}."));
};
let mut global_dictionary = global_dictionary?;
@@ -399,9 +399,13 @@ impl LanguageServer for Backend {
return;
};
- self.update_document(&params.text_document.uri, &last.text, None)
+ if let Err(err) = self
+ .update_document(&params.text_document.uri, &last.text, None)
.await
- .unwrap();
+ {
+ error!("{err}")
+ }
+
self.publish_diagnostics(&params.text_document.uri).await;
}