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

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: Split transformException() out into separate method. 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') | lib/coreimpl/future_implementation.dart » ('J')
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..e4ab4cd107b68c48ff542735014a830bd91cdd1f 100644
--- a/lib/core/future.dart
+++ b/lib/core/future.dart
@@ -123,6 +123,23 @@ 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 exception which will then be sent to the
+ * returned future.
+ *
+ * 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. If it returns `true`, then the exception is
+ * considered handled and is not propagated to the returned future. If it
+ * returns anything else, the original exception will be propagated.
Siggi Cherem (dart-lang) 2012/09/04 20:17:52 thinking about the control flow of this and how si
Bob Nystrom 2012/09/04 21:14:43 Works for me. Done.
+ */
+ Future transformException(bool transformation(Object exception));
nweiz 2012/09/04 20:26:14 It seems like this should just be the default beha
Bob Nystrom 2012/09/04 21:14:43 I'm trying to keep this change as minimally invasi
nweiz 2012/09/04 21:35:35 Sure, seems fine.
}
« no previous file with comments | « no previous file | lib/coreimpl/future_implementation.dart » ('j') | lib/coreimpl/future_implementation.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698