diff --git a/crates/oxc_language_server/src/linter.rs b/crates/oxc_language_server/src/linter.rs index 1bcb56261d25a..c2a0af67e9c35 100644 --- a/crates/oxc_language_server/src/linter.rs +++ b/crates/oxc_language_server/src/linter.rs @@ -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) => {