diff --git a/CHANGELOG.md b/CHANGELOG.md index 13e3a8ea1..237abe834 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,10 @@ ## master +#### :bug: Bug fix + +- Protect against trying to read non-existant `.compiler.log`. https://github.com/rescript-lang/rescript-vscode/pull/1116 + ## 1.64.0 #### :rocket: New Feature diff --git a/server/src/server.ts b/server/src/server.ts index e845b14ca..d51433822 100644 --- a/server/src/server.ts +++ b/server/src/server.ts @@ -99,7 +99,12 @@ let sendUpdatedDiagnostics = async () => { for (const [projectRootPath, projectFile] of projectsFiles) { let { filesWithDiagnostics } = projectFile; let compilerLogPath = path.join(projectRootPath, c.compilerLogPartialPath); - let content = fs.readFileSync(compilerLogPath, { encoding: "utf-8" }); + let content = ""; + try { + content = fs.readFileSync(compilerLogPath, { encoding: "utf-8" }); + } catch (e) { + console.error(`Error reading compiler log file ${compilerLogPath}: ${e}`); + } let { done, result: filesAndErrors,