Skip to content

Commit accb287

Browse files
authored
Try/catch on trying to read compiler log (#1116)
* try/catch on trying to read compiler log, since it sometimes fails * changelog * restore formatting
1 parent fdeb84a commit accb287

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
1313
## master
1414

15+
#### :bug: Bug fix
16+
17+
- Protect against trying to read non-existant `.compiler.log`. https://github.com/rescript-lang/rescript-vscode/pull/1116
18+
1519
## 1.64.0
1620

1721
#### :rocket: New Feature

server/src/server.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,12 @@ let sendUpdatedDiagnostics = async () => {
9999
for (const [projectRootPath, projectFile] of projectsFiles) {
100100
let { filesWithDiagnostics } = projectFile;
101101
let compilerLogPath = path.join(projectRootPath, c.compilerLogPartialPath);
102-
let content = fs.readFileSync(compilerLogPath, { encoding: "utf-8" });
102+
let content = "";
103+
try {
104+
content = fs.readFileSync(compilerLogPath, { encoding: "utf-8" });
105+
} catch (e) {
106+
console.error(`Error reading compiler log file ${compilerLogPath}: ${e}`);
107+
}
103108
let {
104109
done,
105110
result: filesAndErrors,

0 commit comments

Comments
 (0)