OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 part of dart.async; | 5 part of dart.async; |
6 | 6 |
7 typedef dynamic ZoneCallback(); | 7 typedef dynamic ZoneCallback(); |
8 typedef dynamic ZoneUnaryCallback(arg); | 8 typedef dynamic ZoneUnaryCallback(arg); |
9 typedef dynamic ZoneBinaryCallback(arg1, arg2); | 9 typedef dynamic ZoneBinaryCallback(arg1, arg2); |
10 | 10 |
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
694 return new _ZoneDelegate(this).createPeriodicTimer(this, duration, f); | 694 return new _ZoneDelegate(this).createPeriodicTimer(this, duration, f); |
695 } | 695 } |
696 | 696 |
697 void print(String line) { | 697 void print(String line) { |
698 new _ZoneDelegate(this).print(this, line); | 698 new _ZoneDelegate(this).print(this, line); |
699 } | 699 } |
700 } | 700 } |
701 | 701 |
702 void _rootHandleUncaughtError( | 702 void _rootHandleUncaughtError( |
703 Zone self, ZoneDelegate parent, Zone zone, error, StackTrace stackTrace) { | 703 Zone self, ZoneDelegate parent, Zone zone, error, StackTrace stackTrace) { |
704 _scheduleAsyncCallback(() { | 704 self.run(() { |
705 print("Uncaught Error: ${error}"); | 705 _scheduleAsyncCallback(() { |
706 var trace = stackTrace; | 706 print("Uncaught Error: ${error}"); |
707 if (trace == null) trace = getAttachedStackTrace(error); | 707 var trace = stackTrace; |
708 // Clear the attached stack trace (if any). | 708 if (trace == null) trace = getAttachedStackTrace(error); |
709 _attachStackTrace(error, null); | 709 // Clear the attached stack trace (if any). |
710 if (trace != null) { | 710 _attachStackTrace(error, null); |
711 print("Stack Trace: \n$trace\n"); | 711 if (trace != null) { |
712 } | 712 print("Stack Trace: \n$trace\n"); |
713 throw error; | 713 } |
| 714 throw error; |
| 715 }); |
714 }); | 716 }); |
715 } | 717 } |
716 | 718 |
717 dynamic _rootRun(Zone self, ZoneDelegate parent, Zone zone, f()) { | 719 dynamic _rootRun(Zone self, ZoneDelegate parent, Zone zone, f()) { |
718 if (Zone._current == zone) return f(); | 720 if (Zone._current == zone) return f(); |
719 | 721 |
720 Zone old = Zone._current; | 722 Zone old = Zone._current; |
721 try { | 723 try { |
722 Zone._current = zone; | 724 Zone._current = zone; |
723 return f(); | 725 return f(); |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1011 ZoneSpecification specification = | 1013 ZoneSpecification specification = |
1012 new ZoneSpecification(handleUncaughtError: errorHandler, | 1014 new ZoneSpecification(handleUncaughtError: errorHandler, |
1013 scheduleMicrotask: asyncHandler); | 1015 scheduleMicrotask: asyncHandler); |
1014 Zone zone = Zone.current.fork(specification: specification); | 1016 Zone zone = Zone.current.fork(specification: specification); |
1015 if (onError != null) { | 1017 if (onError != null) { |
1016 return zone.runGuarded(body); | 1018 return zone.runGuarded(body); |
1017 } else { | 1019 } else { |
1018 return zone.run(body); | 1020 return zone.run(body); |
1019 } | 1021 } |
1020 } | 1022 } |
OLD | NEW |