Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(163)

Side by Side Diff: corelib/src/implementation/future_implementation.dart

Issue 9155017: Handle defered handling of exceptions (where the exception is thrown before the (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: quick typo fix Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 if (hasValue) { 84 if (hasValue) {
85 onComplete(value); 85 onComplete(value);
86 } else if (!isComplete) { 86 } else if (!isComplete) {
87 _listeners.add(onComplete); 87 _listeners.add(onComplete);
88 } else if (!_exceptionHandled) { 88 } else if (!_exceptionHandled) {
89 throw _exception; 89 throw _exception;
90 } 90 }
91 } 91 }
92 92
93 void handleException(void onException(Object exception)) { 93 void handleException(void onException(Object exception)) {
94 _exceptionHandlers.add(onException); 94 if (null !== _exception) {
Siggi Cherem (dart-lang) 2012/01/21 01:50:38 (swap): _expression !== null
95 if (!_exceptionHandled) {
96 _exceptionHandled = onException(exception);
97 }
98 } else {
99 _exceptionHandlers.add(onException);
100 }
95 } 101 }
96 102
97 void _complete() { 103 void _complete() {
98 _isComplete = true; 104 _isComplete = true;
99 if (_exception !== null) { 105 if (_exception !== null) {
100 for (Function handler in _exceptionHandlers) { 106 for (Function handler in _exceptionHandlers) {
101 if (handler(_exception)) { 107 if (handler(_exception)) {
102 _exceptionHandled = true; 108 _exceptionHandled = true;
103 break; 109 break;
104 } 110 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 } 153 }
148 154
149 void complete(T value) { 155 void complete(T value) {
150 _futureImpl._setValue(value); 156 _futureImpl._setValue(value);
151 } 157 }
152 158
153 void completeException(var exception) { 159 void completeException(var exception) {
154 _futureImpl._setException(exception); 160 _futureImpl._setException(exception);
155 } 161 }
156 } 162 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698