| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library driver; | 5 library driver; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:io'; | 8 import 'dart:io'; |
| 9 import 'dart:math'; | 9 import 'dart:math'; |
| 10 | 10 |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 } | 460 } |
| 461 | 461 |
| 462 /** | 462 /** |
| 463 * Execute the given [callback] within a zone that will capture any unhandled | 463 * Execute the given [callback] within a zone that will capture any unhandled |
| 464 * exceptions and both report them to the client and send them to the given | 464 * exceptions and both report them to the client and send them to the given |
| 465 * instrumentation [service]. If a [print] function is provided, then also | 465 * instrumentation [service]. If a [print] function is provided, then also |
| 466 * capture any data printed by the callback and redirect it to the function. | 466 * capture any data printed by the callback and redirect it to the function. |
| 467 */ | 467 */ |
| 468 dynamic _captureExceptions(InstrumentationService service, dynamic callback(), | 468 dynamic _captureExceptions(InstrumentationService service, dynamic callback(), |
| 469 {void print(String line)}) { | 469 {void print(String line)}) { |
| 470 Function errorFunction = (Zone self, ZoneDelegate parent, Zone zone, | 470 var errorFunction = (Zone self, ZoneDelegate parent, Zone zone, |
| 471 dynamic exception, StackTrace stackTrace) { | 471 dynamic exception, StackTrace stackTrace) { |
| 472 service.logPriorityException(exception, stackTrace); | 472 service.logPriorityException(exception, stackTrace); |
| 473 AnalysisServer analysisServer = socketServer.analysisServer; | 473 AnalysisServer analysisServer = socketServer.analysisServer; |
| 474 analysisServer.sendServerErrorNotification( | 474 analysisServer.sendServerErrorNotification( |
| 475 'Captured exception', exception, stackTrace); | 475 'Captured exception', exception, stackTrace); |
| 476 throw exception; | 476 throw exception; |
| 477 }; | 477 }; |
| 478 Function printFunction = print == null | 478 var printFunction = print == null |
| 479 ? null | 479 ? null |
| 480 : (Zone self, ZoneDelegate parent, Zone zone, String line) { | 480 : (Zone self, ZoneDelegate parent, Zone zone, String line) { |
| 481 // Note: we don't pass the line on to stdout, because that is reserv
ed | 481 // Note: we don't pass the line on to stdout, because that is |
| 482 // for communication to the client. | 482 // reserved for communication to the client. |
| 483 print(line); | 483 print(line); |
| 484 }; | 484 }; |
| 485 ZoneSpecification zoneSpecification = new ZoneSpecification( | 485 ZoneSpecification zoneSpecification = new ZoneSpecification( |
| 486 handleUncaughtError: errorFunction, print: printFunction); | 486 handleUncaughtError: errorFunction, print: printFunction); |
| 487 return runZoned(callback, zoneSpecification: zoneSpecification); | 487 return runZoned(callback, zoneSpecification: zoneSpecification); |
| 488 } | 488 } |
| 489 | 489 |
| 490 /** | 490 /** |
| 491 * Create and return the parser used to parse the command-line arguments. | 491 * Create and return the parser used to parse the command-line arguments. |
| 492 */ | 492 */ |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 602 */ | 602 */ |
| 603 static void _rollLogFiles(String path, int numOld) { | 603 static void _rollLogFiles(String path, int numOld) { |
| 604 for (int i = numOld - 1; i >= 0; i--) { | 604 for (int i = numOld - 1; i >= 0; i--) { |
| 605 try { | 605 try { |
| 606 String oldPath = i == 0 ? path : '$path.$i'; | 606 String oldPath = i == 0 ? path : '$path.$i'; |
| 607 new File(oldPath).renameSync('$path.${i+1}'); | 607 new File(oldPath).renameSync('$path.${i+1}'); |
| 608 } catch (e) {} | 608 } catch (e) {} |
| 609 } | 609 } |
| 610 } | 610 } |
| 611 } | 611 } |
| OLD | NEW |