Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 Google Inc. All Rights Reserved. | 1 // Copyright 2011 Google Inc. All Rights Reserved. |
| 2 // Dart core library. | 2 // Dart core library. |
| 3 | 3 |
| 4 /** | 4 /** |
| 5 * Thrown if client tries to obtain value or exception | 5 * Thrown if client tries to obtain value or exception |
| 6 * before a future has completed. | 6 * before a future has completed. |
| 7 */ | 7 */ |
| 8 class FutureNotCompleteException implements Exception { | 8 class FutureNotCompleteException implements Exception { |
| 9 FutureNotCompleteException() {} | 9 FutureNotCompleteException() {} |
| 10 String toString() => "Exception: future has not been completed"; | 10 String toString() => "Exception: future has not been completed"; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 void handleException(void onException(Object exception)) { | 93 void handleException(void onException(Object exception)) { |
| 94 _exceptionHandlers.add(onException); | 94 _exceptionHandlers.add(onException); |
| 95 } | 95 } |
| 96 | 96 |
| 97 void _complete() { | 97 void _complete() { |
| 98 _isComplete = true; | 98 _isComplete = true; |
| 99 if (_exception !== null) { | 99 if (_exception !== null) { |
| 100 for (Function handler in _exceptionHandlers) { | 100 for (Function handler in _exceptionHandlers) { |
| 101 if (handler(_exception)) { | 101 if (handler(_exception)) { |
| 102 _exceptionHandled = true; | 102 _exceptionHandled = true; |
| 103 break; | |
|
Siggi Cherem (dart-lang)
2011/12/28 20:11:59
Matt - Something I wanted to make sure here is thi
mattsh
2011/12/28 20:55:57
Yes. This is good.
| |
| 103 } | 104 } |
| 104 } | 105 } |
| 105 } | 106 } |
| 106 if (hasValue) { | 107 if (hasValue) { |
| 107 for (Function listener in _listeners) { | 108 for (Function listener in _listeners) { |
| 108 listener(value); | 109 listener(value); |
| 109 } | 110 } |
| 110 } else { | 111 } else { |
| 111 if (!_exceptionHandled && _listeners.length > 0) { | 112 if (!_exceptionHandled && _listeners.length > 0) { |
| 112 throw _exception; | 113 throw _exception; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 146 } | 147 } |
| 147 | 148 |
| 148 void complete(T value) { | 149 void complete(T value) { |
| 149 _futureImpl._setValue(value); | 150 _futureImpl._setValue(value); |
| 150 } | 151 } |
| 151 | 152 |
| 152 void completeException(var exception) { | 153 void completeException(var exception) { |
| 153 _futureImpl._setException(exception); | 154 _futureImpl._setException(exception); |
| 154 } | 155 } |
| 155 } | 156 } |
| OLD | NEW |