Chromium Code Reviews| 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); |
| } |