Skip to content

Commit 5da1df8

Browse files
committed
Better errors
1 parent 7bd7cb3 commit 5da1df8

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

crates/codebook-lsp/src/lsp.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,18 @@ impl LanguageServer for Backend {
161161
}
162162
let cb = self.codebook.clone();
163163
let inner_word = word.clone();
164-
let suggestions = task::spawn_blocking(move || cb.get_suggestions(&inner_word))
165-
.await
166-
.unwrap();
164+
let suggestions = task::spawn_blocking(move || cb.get_suggestions(&inner_word)).await;
165+
166+
let suggestions = match suggestions {
167+
Ok(suggestions) => suggestions,
168+
Err(e) => {
169+
error!(
170+
"Error getting suggestions for word '{}' in file '{:?}'\n Error: {}",
171+
word, doc.uri, e
172+
);
173+
return Ok(None);
174+
}
175+
};
167176

168177
if suggestions.is_none() {
169178
return Ok(None);
@@ -351,7 +360,7 @@ impl Backend {
351360
Ok(results) => results,
352361
Err(err) => {
353362
error!(
354-
"Spell-checking failed for file: {:?} \n Error: {}",
363+
"Spell-checking failed for file '{:?}' \n Error: {}",
355364
file_path, err
356365
);
357366
return;

0 commit comments

Comments
 (0)