| OLD | NEW |
| 1 library catch_errors; | 1 library catch_errors; |
| 2 | 2 |
| 3 import 'dart:async'; | 3 import 'dart:async'; |
| 4 | 4 |
| 5 Stream catchErrors(void body()) { | 5 Stream catchErrors(void body()) { |
| 6 StreamController controller; | 6 StreamController controller; |
| 7 | 7 |
| 8 bool onError(e, st) { | 8 bool onError(e, st) { |
| 9 controller.add(e); | 9 controller.add(e); |
| 10 return true; | 10 return true; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 } | 39 } |
| 40 }; | 40 }; |
| 41 } | 41 } |
| 42 ScheduleMicrotaskHandler asyncHandler; | 42 ScheduleMicrotaskHandler asyncHandler; |
| 43 if (onScheduleMicrotask != null) { | 43 if (onScheduleMicrotask != null) { |
| 44 asyncHandler = (Zone self, ZoneDelegate parent, Zone zone, f()) { | 44 asyncHandler = (Zone self, ZoneDelegate parent, Zone zone, f()) { |
| 45 self.parent.runUnary(onScheduleMicrotask, () => zone.runGuarded(f)); | 45 self.parent.runUnary(onScheduleMicrotask, () => zone.runGuarded(f)); |
| 46 }; | 46 }; |
| 47 } | 47 } |
| 48 ZoneSpecification specification = | 48 ZoneSpecification specification = |
| 49 new ZoneSpecification(handleUncaughtError: errorHandler, | 49 new ZoneSpecification(handleUncaughtError: errorHandler, |
| 50 scheduleMicrotask: asyncHandler); | 50 scheduleMicrotask: asyncHandler); |
| 51 Zone zone = Zone.current.fork(specification: specification); | 51 Zone zone = Zone.current.fork(specification: specification); |
| 52 if (onError != null) { | 52 if (onError != null) { |
| 53 return zone.runGuarded(body); | 53 return zone.runGuarded(body); |
| 54 } else { | 54 } else { |
| 55 return zone.run(body); | 55 return zone.run(body); |
| 56 } | 56 } |
| 57 } | 57 } |
| OLD | NEW |