Be more discriminating in failure popups#1022
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
| // the code couldn't be submitted to the runtime at all (e.g. | ||
| // no runtime is registered for the language), which is a | ||
| // genuine problem worth reporting. | ||
| let runtimeFailure = false; |
There was a problem hiding this comment.
This logic depends on onFailed having already fired (synchronously setting runtimeFailure) by the time we reach this catch. The ExecutionObserver docs only guarantee that one of onCompleted/onFailed is called, not their ordering relative to the executeCode promise rejecting. If that ordering ever changed or raced, a runtime error would be misclassified as a submission failure and we'd surface the popup again. Just noting the dependency for future readers; the failure mode is only a graceful regression to the old behavior, so nothing to change here IMO.
There was a problem hiding this comment.
Yes, it's a little kludgy! I think a more complete fix might be to throw specific structured error classes from Positron to distinguish "can't run code at all" errors from "code ran but it failed" errors.

This change prevents superfluous error notifications/toasts when running cells in Positron.
The issue was that we were not catching exceptions thrown by
executeCode. It is appropriate for exceptions to propagate here when we can't execute the code for some structural reason, but most often the failure is caused by the code itself.When a cell fails to execute (a runtime/syntax error, an interrupt, or the session exiting) Positron already reports it in the console. Previously the rejection from
executeCodealso propagated up to the command handler, which surfaced it a second time as a notification popup.This change distinguishes the two failure modes via the execution observer's
onFailedcallback:Fixes posit-dev/positron#9845