Index: sdk/lib/core/future_impl.dart |
diff --git a/sdk/lib/core/future_impl.dart b/sdk/lib/core/future_impl.dart |
index 2c22e46123115e6b3dd852f5ed4fc5333f1975c7..bbae82d1667ffaff49b056c537143ee23b10d050 100644 |
--- a/sdk/lib/core/future_impl.dart |
+++ b/sdk/lib/core/future_impl.dart |
@@ -27,11 +27,6 @@ class _FutureImpl<T> implements Future<T> { |
bool _exceptionHandled = false; |
/** |
- * true if an exception in this future should be thrown to the top level. |
- */ |
- bool _throwOnException = false; |
- |
- /** |
* Listeners waiting to receive the value of this future. |
*/ |
final List<Function> _successListeners; |
@@ -93,21 +88,12 @@ class _FutureImpl<T> implements Future<T> { |
if (hasValue) { |
onSuccess(value); |
} else if (!isComplete) { |
- _throwOnException = true; |
_successListeners.add(onSuccess); |
} else if (!_exceptionHandled) { |
throw new FutureUnhandledException(_exception, stackTrace); |
} |
} |
- void _handleSuccess(void onSuccess(T value)) { |
- if (hasValue) { |
- onSuccess(value); |
- } else if (!isComplete) { |
- _successListeners.add(onSuccess); |
- } |
- } |
- |
void handleException(bool onException(Object exception)) { |
if (_exceptionHandled) return; |
if (_isComplete) { |
@@ -149,7 +135,7 @@ class _FutureImpl<T> implements Future<T> { |
listener(value); |
} |
} else { |
- if (!_exceptionHandled && _throwOnException) { |
+ if (!_exceptionHandled && _successListeners.length > 0) { |
throw new FutureUnhandledException(_exception, stackTrace); |
} |
} |
@@ -188,7 +174,7 @@ class _FutureImpl<T> implements Future<T> { |
_forwardException(this, completer); |
- _handleSuccess((v) { |
+ then((v) { |
var transformed = null; |
try { |
transformed = transformation(v); |
@@ -206,7 +192,7 @@ class _FutureImpl<T> implements Future<T> { |
final completer = new Completer(); |
_forwardException(this, completer); |
- _handleSuccess((v) { |
+ then((v) { |
var future = null; |
try { |
future = transformation(v); |
@@ -237,10 +223,10 @@ class _FutureImpl<T> implements Future<T> { |
} catch (innerException, stackTrace) { |
completer.completeException(innerException, stackTrace); |
} |
- return false; |
+ return true; |
}); |
- _handleSuccess(completer.complete); |
+ then(completer.complete); |
return completer.future; |
} |
@@ -250,7 +236,7 @@ class _FutureImpl<T> implements Future<T> { |
*/ |
_forward(Future future, Completer completer) { |
_forwardException(future, completer); |
- future._handleSuccess(completer.complete); |
+ future.then(completer.complete); |
} |
/** |
@@ -259,7 +245,7 @@ class _FutureImpl<T> implements Future<T> { |
_forwardException(Future future, Completer completer) { |
future.handleException((e) { |
completer.completeException(e, future.stackTrace); |
- return false; |
+ return true; |
}); |
} |
} |