| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 deprecatedFutureValue(_FutureImpl future) => | 7 deprecatedFutureValue(_FutureImpl future) => |
| 8 future._isComplete ? future._resultOrListeners : null; | 8 future._isComplete ? future._resultOrListeners : null; |
| 9 | 9 |
| 10 abstract class _Completer<T> implements Completer<T> { | 10 abstract class _Completer<T> implements Completer<T> { |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 listeners = listener._nextListener; | 210 listeners = listener._nextListener; |
| 211 listener._nextListener = null; | 211 listener._nextListener = null; |
| 212 listener._sendError(error); | 212 listener._sendError(error); |
| 213 } while (listeners != null); | 213 } while (listeners != null); |
| 214 } | 214 } |
| 215 | 215 |
| 216 void _scheduleUnhandledError() { | 216 void _scheduleUnhandledError() { |
| 217 _state |= _UNHANDLED_ERROR; | 217 _state |= _UNHANDLED_ERROR; |
| 218 // Wait for the rest of the current event's duration to see | 218 // Wait for the rest of the current event's duration to see |
| 219 // if a subscriber is added to handle the error. | 219 // if a subscriber is added to handle the error. |
| 220 Timer.run(() { | 220 runAsync(() { |
| 221 if (_hasUnhandledError) { | 221 if (_hasUnhandledError) { |
| 222 // No error handler has been added since the error was set. | 222 // No error handler has been added since the error was set. |
| 223 _clearUnhandledError(); | 223 _clearUnhandledError(); |
| 224 var error = _resultOrListeners; | 224 var error = _resultOrListeners; |
| 225 print("Uncaught Error: ${error}"); | 225 print("Uncaught Error: ${error}"); |
| 226 var trace = getAttachedStackTrace(error); | 226 var trace = getAttachedStackTrace(error); |
| 227 if (trace != null) { | 227 if (trace != null) { |
| 228 print("Stack Trace:\n$trace\n"); | 228 print("Stack Trace:\n$trace\n"); |
| 229 } | 229 } |
| 230 throw error; | 230 throw error; |
| 231 } | 231 } |
| 232 }); | 232 }); |
| 233 } | 233 } |
| 234 | 234 |
| 235 void _addListener(_FutureListener listener) { | 235 void _addListener(_FutureListener listener) { |
| 236 if (_isComplete) { | 236 if (_isComplete) { |
| 237 _clearUnhandledError(); | 237 _clearUnhandledError(); |
| 238 // Handle late listeners asynchronously. | 238 // Handle late listeners asynchronously. |
| 239 Timer.run(() { | 239 runAsync(() { |
| 240 if (_hasValue) { | 240 if (_hasValue) { |
| 241 T value = _resultOrListeners; | 241 T value = _resultOrListeners; |
| 242 listener._sendValue(value); | 242 listener._sendValue(value); |
| 243 } else { | 243 } else { |
| 244 assert(_hasError); | 244 assert(_hasError); |
| 245 listener._sendError(_resultOrListeners); | 245 listener._sendError(_resultOrListeners); |
| 246 } | 246 } |
| 247 }); | 247 }); |
| 248 } else { | 248 } else { |
| 249 assert(!_isComplete); | 249 assert(!_isComplete); |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 _setError(error); | 464 _setError(error); |
| 465 }, onError: _setError); | 465 }, onError: _setError); |
| 466 return; | 466 return; |
| 467 } | 467 } |
| 468 } catch (e, s) { | 468 } catch (e, s) { |
| 469 error = _asyncError(e, s); | 469 error = _asyncError(e, s); |
| 470 } | 470 } |
| 471 _setError(error); | 471 _setError(error); |
| 472 } | 472 } |
| 473 } | 473 } |
| OLD | NEW |