Chromium Code Reviews| 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. |
| }); |