Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

Commit 26cba06

Browse files
committed
chore(mock zone): sync() zone should also catch async exceptions
1 parent 56a1770 commit 26cba06

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/mock/zone.dart

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,8 @@ _createTimer(Function fn, Duration duration, bool periodic) {
192192
* will throw an exception.
193193
*/
194194
sync(Function fn) => () {
195+
_asyncErrors.clear();
196+
195197
dart_async.runZoned(fn, zoneSpecification: new dart_async.ZoneSpecification(
196198
scheduleMicrotask: (_, __, ___, asyncFn) {
197199
throw ['scheduleMicrotask called from sync function.'];
@@ -202,8 +204,13 @@ sync(Function fn) => () {
202204
createPeriodicTimer:
203205
(_, __, ___, Duration period, void f(dart_async.Timer timer)) {
204206
throw ['periodic Timer created from sync function.'];
205-
}
207+
},
208+
handleUncaughtError: (_, __, ___, e, s) => _asyncErrors.add([e, s])
206209
));
210+
211+
_asyncErrors.forEach((e) {
212+
throw "During runZoned: ${e[0]}. Stack:\n${e[1]}";
213+
});
207214
};
208215

209216
class _TimerSpec implements dart_async.Timer {

0 commit comments

Comments
 (0)