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

Unified Diff: lib/core/future.dart

Issue 10908040: Support transforming the exception in Future.transform(). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Allow transformException to complete successfully. 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 | « no previous file | lib/coreimpl/future_implementation.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/core/future.dart
diff --git a/lib/core/future.dart b/lib/core/future.dart
index 6b2fa19e3e82b3c5abb094af4f21570117fab0a5..d0cda97769dcaf6abfa1fca55d770c128d7c13a1 100644
--- a/lib/core/future.dart
+++ b/lib/core/future.dart
@@ -123,8 +123,20 @@ interface Future<T> default FutureImpl<T> {
* chain, and any you add afterwards will not be invoked.
*/
Future chain(Future transformation(T value));
-}
+ /**
+ * A future representing [transformation] applied to this future's exception.
+ * This can be used to "catch" an exception coming from `this` and translate
+ * it to a more appropriate result.
+ *
+ * If this future gets a value, it simply completes to that same value. If an
+ * exception occurs, then [transformation] will be called with the exception
+ * value. If [transformation] itself throws an exception, then the returned
+ * future completes with that exception. Otherwise, the future will complete
+ * with the value returned by [transformation].
+ */
+ Future transformException(transformation(Object exception));
+}
/**
* A [Completer] is used to produce [Future]s and supply their value when it
« no previous file with comments | « no previous file | lib/coreimpl/future_implementation.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698