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 library error_group; | 5 library error_group; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'utils.dart'; | 9 import 'utils.dart'; |
10 | 10 |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 future._signalError(error); | 122 future._signalError(error); |
123 } | 123 } |
124 | 124 |
125 for (var stream in _streams) { | 125 for (var stream in _streams) { |
126 if (stream._isDone || stream._hasListeners) caught = true; | 126 if (stream._isDone || stream._hasListeners) caught = true; |
127 stream._signalError(error); | 127 stream._signalError(error); |
128 } | 128 } |
129 | 129 |
130 _isDone = true; | 130 _isDone = true; |
131 _done._signalError(error); | 131 _done._signalError(error); |
132 if (!caught && !_done._hasListeners) error.throwDelayed(); | 132 if (!caught && !_done._hasListeners) runAsync((){ throw error; }); |
133 } | 133 } |
134 | 134 |
135 /// Notifies [this] that one of its member [Future]s is complete. | 135 /// Notifies [this] that one of its member [Future]s is complete. |
136 void _signalFutureComplete(_ErrorGroupFuture future) { | 136 void _signalFutureComplete(_ErrorGroupFuture future) { |
137 if (_isDone) return; | 137 if (_isDone) return; |
138 | 138 |
139 _isDone = _futures.every((future) => future._isDone) && | 139 _isDone = _futures.every((future) => future._isDone) && |
140 _streams.every((stream) => stream._isDone); | 140 _streams.every((stream) => stream._isDone); |
141 if (_isDone) _doneCompleter.complete(); | 141 if (_isDone) _doneCompleter.complete(); |
142 } | 142 } |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 void _signalError(var e) { | 268 void _signalError(var e) { |
269 if (_isDone) return; | 269 if (_isDone) return; |
270 _subscription.cancel(); | 270 _subscription.cancel(); |
271 // Call these asynchronously to work around issue 7913. | 271 // Call these asynchronously to work around issue 7913. |
272 new Future.value().then((_) { | 272 new Future.value().then((_) { |
273 _controller.addError(e); | 273 _controller.addError(e); |
274 _controller.close(); | 274 _controller.close(); |
275 }); | 275 }); |
276 } | 276 } |
277 } | 277 } |
OLD | NEW |