Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pop up error when loading file #1867

Merged
merged 1 commit into from
Sep 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Changes to Calva.

## [Unreleased]

- [Show error message if loading file results in an error](https://github.com/BetterThanTomorrow/calva/issues/1767)

## [2.0.301] - 2022-09-16

- Fix test running issue: [Two references to the same class in the same namespace can refer to two different instances of the class](https://github.com/BetterThanTomorrow/calva/issues/1821)
Expand Down
22 changes: 21 additions & 1 deletion src/evaluate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -423,11 +423,15 @@ async function loadFile(

await session.switchNS(ns);

const errorMessages = [];
const res = session.loadFile(fileContents, {
fileName,
filePath: docUri.path,
stdout: (m) => outputWindow.append(normalizeNewLines(m)),
stderr: (m) => outputWindow.append('; ' + normalizeNewLines(m, true)),
stderr: (m) => {
outputWindow.append('; ' + normalizeNewLines(m, true));
errorMessages.push(normalizeNewLines(m, true));
},
pprintOptions: pprintOptions,
});
try {
Expand All @@ -447,6 +451,22 @@ async function loadFile(
}
}
);
if (
!vscode.window.visibleTextEditors.find((editor: vscode.TextEditor) =>
outputWindow.isResultsDoc(editor.document)
)
) {
void vscode.window
.showErrorMessage(
`Evaluation of file ${fileName} failed: ${errorMessages.join(' ')} - ${e}`,
'Show output'
)
.then((choice) => {
if (choice === 'Show output') {
void vscode.commands.executeCommand('calva.showOutputWindow');
}
});
}
}
outputWindow.setSession(session, res.ns || ns);
replSession.updateReplSessionType();
Expand Down