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

Unified Diff: lib/coreimpl/future_implementation.dart

Issue 10958021: If transformException() returns a future, act like chain(). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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 | « lib/core/future.dart ('k') | tests/corelib/future_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/coreimpl/future_implementation.dart
diff --git a/lib/coreimpl/future_implementation.dart b/lib/coreimpl/future_implementation.dart
index 15e4f2a0f2721f3ca5fa1ae679122b1d9e4e2a49..febe8b845b14c4ac0a3db4365ac8ab9514c899f5 100644
--- a/lib/coreimpl/future_implementation.dart
+++ b/lib/coreimpl/future_implementation.dart
@@ -219,7 +219,19 @@ class FutureImpl<T> implements Future<T> {
handleException((ex) {
try {
- completer.complete(transformation(ex));
+ final result = transformation(ex);
+
+ // If the transformation itself returns a future, then we will
+ // complete to what that completes to.
+ if (result is Future) {
+ result.handleException((e) {
+ completer.completeException(e, result.stackTrace);
+ return true;
+ });
+ result.then((value) => completer.complete(value));
Siggi Cherem (dart-lang) 2012/09/20 22:00:17 I've seen the pattern of the last 4 lines quite a
Bob Nystrom 2012/09/20 22:34:53 Done. I put it in _FutureImpl (which, by the way,
+ } else {
+ completer.complete(result);
+ }
} catch (innerException, stackTrace) {
completer.completeException(innerException, stackTrace);
}
« no previous file with comments | « lib/core/future.dart ('k') | tests/corelib/future_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698