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

Unified Diff: corelib/src/implementation/future_implementation.dart

Issue 9533014: futures: handle exceptions immediately if the future already completed. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/corelib/src/FutureTest.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: corelib/src/implementation/future_implementation.dart
diff --git a/corelib/src/implementation/future_implementation.dart b/corelib/src/implementation/future_implementation.dart
index 48c7d405b7c0d58f31143d1268c6ac93c1d66a79..be56fe6f83efc572f8300015bcfe0c4397b5ab34 100644
--- a/corelib/src/implementation/future_implementation.dart
+++ b/corelib/src/implementation/future_implementation.dart
@@ -94,8 +94,15 @@ class FutureImpl<T> implements Future<T> {
}
}
- void handleException(void onException(Object exception)) {
- _exceptionHandlers.add(onException);
+ void handleException(bool onException(Object exception)) {
+ if (_exceptionHandled) return;
+ if (_isComplete) {
+ if (_exception != null) {
+ _exceptionHandled = onException(_exception);
+ }
+ } else {
+ _exceptionHandlers.add(onException);
+ }
}
void _complete() {
« no previous file with comments | « no previous file | tests/corelib/src/FutureTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698