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

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

Issue 9272005: Revert "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: 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 if (_exception !== null) { 94 _exceptionHandlers.add(onException);
95 if (!_exceptionHandled) {
96 _exceptionHandled = onException(exception);
97 }
98 } else {
99 _exceptionHandlers.add(onException);
100 }
101 } 95 }
102 96
103 void _complete() { 97 void _complete() {
104 _isComplete = true; 98 _isComplete = true;
105 if (_exception !== null) { 99 if (_exception !== null) {
106 for (Function handler in _exceptionHandlers) { 100 for (Function handler in _exceptionHandlers) {
107 if (handler(_exception)) { 101 if (handler(_exception)) {
108 _exceptionHandled = true; 102 _exceptionHandled = true;
109 break; 103 break;
110 } 104 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 } 147 }
154 148
155 void complete(T value) { 149 void complete(T value) {
156 _futureImpl._setValue(value); 150 _futureImpl._setValue(value);
157 } 151 }
158 152
159 void completeException(var exception) { 153 void completeException(var exception) {
160 _futureImpl._setException(exception); 154 _futureImpl._setException(exception);
161 } 155 }
162 } 156 }
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