Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(313)

Unified Diff: pkg/analysis_server/lib/src/analysis_server.dart

Issue 302323002: Add a boolean which causes AnalysisServer to rethrow exceptions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/socket_server.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/analysis_server.dart
diff --git a/pkg/analysis_server/lib/src/analysis_server.dart b/pkg/analysis_server/lib/src/analysis_server.dart
index 80cc62451c9a2d77e01ce8c54f0118b3ab94299c..016fe802b30a605b8f9d44ff2441d7937be3b587 100644
--- a/pkg/analysis_server/lib/src/analysis_server.dart
+++ b/pkg/analysis_server/lib/src/analysis_server.dart
@@ -22,6 +22,7 @@ import 'package:analyzer/src/generated/sdk.dart';
import 'package:analyzer/src/generated/sdk_io.dart';
import 'package:analyzer/src/generated/source_io.dart';
import 'package:analysis_server/src/computers.dart';
+import 'package:analyzer/src/generated/java_engine.dart';
/**
@@ -126,10 +127,22 @@ class AnalysisServer {
Map<AnalysisService, Set<String>> analysisServices = <AnalysisService, Set<String>>{};
/**
+ * True if any exceptions thrown by analysis should be propagated up the call
+ * stack.
+ */
+ bool rethrowExceptions;
+
+ /**
* Initialize a newly created server to receive requests from and send
* responses to the given [channel].
+ *
+ * If [rethrowExceptions] is true, then any exceptions thrown by analysis are
+ * propagated up the call stack. The default is true to allow analysis
+ * exceptions to show up in unit tests, but it should be set to false when
+ * running a full analysis server.
*/
- AnalysisServer(this.channel, ResourceProvider resourceProvider) {
+ AnalysisServer(this.channel, ResourceProvider resourceProvider,
+ {this.rethrowExceptions: true}) {
contextDirectoryManager = new AnalysisServerContextDirectoryManager(this, resourceProvider);
AnalysisEngine.instance.logger = new AnalysisLogger();
running = true;
@@ -225,6 +238,13 @@ class AnalysisServer {
sendStatusNotification(context.toString());
AnalysisResult result = context.performAnalysisTask();
notices = result.changeNotices;
+ } catch (exception, stackTrace) {
+ AnalysisEngine.instance.logger.logError("${exception}\n${stackTrace}");
+ if (rethrowExceptions) {
+ throw new AnalysisException(
+ 'Unexpected exception during analysis',
+ new CaughtException(exception, stackTrace));
+ }
} finally {
if (notices == null) {
// Either we have no more work to do for this context, or there was an
@@ -451,9 +471,7 @@ class AnalysisServer {
}
void _scheduleTask() {
- new Future(performTask).catchError((ex, st) {
- AnalysisEngine.instance.logger.logError("${ex}\n${st}");
- });
+ new Future(performTask);
}
}
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/socket_server.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698