Skip to content

Commit

Permalink
fix(lsp): improve err handling when loading source text (#8025)
Browse files Browse the repository at this point in the history
note i didn't test this, but it's panicing because `fs::read_to_string` is returning an error as the path no longer exists.

fixes #8023
  • Loading branch information
camc314 committed Dec 19, 2024
1 parent 0f9308f commit 6344b93
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions crates/oxc_language_server/src/linter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,7 @@ impl IsolatedLintHandler {
debug!("extension not supported yet.");
return None;
}
let source_text = source_text.map_or_else(
|| fs::read_to_string(path).unwrap_or_else(|_| panic!("Failed to read {path:?}")),
|source_text| source_text,
);
let source_text = source_text.or_else(|| fs::read_to_string(path).ok())?;
let javascript_sources = match self.loader.load_str(path, &source_text) {
Ok(s) => s,
Err(e) => {
Expand Down

0 comments on commit 6344b93

Please sign in to comment.