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

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

Issue 811223002: Capture and report uncaught exceptions in server (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years 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/analysis_server.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/driver.dart
diff --git a/pkg/analysis_server/lib/driver.dart b/pkg/analysis_server/lib/driver.dart
index 55616e9ffb1dca49aa481cc790a4a49607f94e9f..ebf2cce5499dd1f51632705cb9e171840333a51a 100644
--- a/pkg/analysis_server/lib/driver.dart
+++ b/pkg/analysis_server/lib/driver.dart
@@ -230,15 +230,17 @@ class Driver {
}
if (results[INTERNAL_PRINT_TO_CONSOLE]) {
Paul Berry 2014/12/18 18:57:38 Consider getting rid of the code duplication with:
Brian Wilkerson 2014/12/19 15:55:01 Done
- stdioServer.serveStdio().then((_) {
- if (serve_http) {
- httpServer.close();
- }
- service.shutdown();
- exit(0);
+ _captureExceptions(() {
+ stdioServer.serveStdio().then((_) {
+ if (serve_http) {
+ httpServer.close();
+ }
+ service.shutdown();
+ exit(0);
+ });
});
} else {
- _capturePrints(() {
+ _captureExceptions(() {
stdioServer.serveStdio().then((_) {
if (serve_http) {
httpServer.close();
@@ -246,18 +248,24 @@ class Driver {
service.shutdown();
exit(0);
});
- }, httpServer.recordPrint);
+ }, print: httpServer.recordPrint);
}
}
/**
- * Execute [callback], capturing any data it prints out and redirecting it to
- * the function [printHandler].
+ * Execute the given [callback], capturing any unhandled exceptions and
+ * reporting them to the client. If a [printHandler] function is provided,
+ * then also capture any data printed by the callback and redirect it to the
+ * [printHandler].
*/
- dynamic _capturePrints(dynamic callback(), void printHandler(String line)) {
+ dynamic _captureExceptions(dynamic callback(), {void print(String line)}) {
ZoneSpecification zoneSpecification = new ZoneSpecification(
- print: (Zone self, ZoneDelegate parent, Zone zone, String line) {
- printHandler(line);
+ handleUncaughtError: (Zone self, ZoneDelegate parent, Zone zone,
+ dynamic exception, StackTrace stackTrace) {
+ socketServer.analysisServer.reportException(exception, stackTrace);
+ throw exception;
+ }, print: (Zone self, ZoneDelegate parent, Zone zone, String line) {
+ print(line);
Paul Berry 2014/12/18 18:57:38 Won't this lead to a null reference exception if t
Brian Wilkerson 2014/12/19 15:55:01 Done
// Note: we don't pass the line on to stdout, because that is reserved
// for communication to the client.
});
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/analysis_server.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698