Skip to content

Commit 0067513

Browse files
srawlinsCommit Queue
authored andcommitted
DAS plugins: properly throw and catch when a plugin cannot start
I noticed, when running `dart analyze`, that when `pub upgrade` could not be run in a plugin directory, we would get the "An error occurred while setting up ..." message (good), but then the plugin would still be executed! And this message would get printed: > An unexpected error was encountered by the Analysis Server. > Please file an issue at https://github.com/dart-lang/sdk/issues/new/choose with the following details: > > Internal error: Issue stopping a plugin > Bad state: Cannot stop a plugin that is not running. The reason is that a PluginException was _only_ thrown, on line 560, if the package config file was still _missing_. But in my case, the plugin directory was pre-existing, from an earlier, successful run, and so the package config file existed! So no exception was thrown, and the server still attempted to run the plugin. So this CL makes that whole situation much simpler, and in particular removes the erroneous "An unexpected error was encountered by the Analysis Server" message that we do not want to show to users, and an extra stack trace. Change-Id: I9be39d10b687e055392f9b81285c99cca4c57534 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/453140 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Samuel Rawlins <[email protected]>
1 parent dc8b8fe commit 0067513

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

pkg/analysis_server/lib/src/plugin/plugin_manager.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -551,9 +551,7 @@ class PluginManager {
551551
buffer.writeln(' exitCode = ${pubResult.exitCode}');
552552
buffer.writeln(' stdout = ${pubResult.stdout}');
553553
buffer.writeln(' stderr = ${pubResult.stderr}');
554-
exceptionReason = buffer.toString();
555-
instrumentationService.logError(exceptionReason);
556-
_notificationManager.handlePluginError(exceptionReason);
554+
throw PluginException(buffer.toString());
557555
}
558556
if (!packageConfigFile.exists) {
559557
exceptionReason ??= 'File "${packageConfigFile.path}" does not exist.';

0 commit comments

Comments
 (0)