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

Side by Side Diff: sdk/lib/async/future.dart

Issue 2718643003: fix future onError handler wrapping to avoid cast error (Closed)
Patch Set: take 2 Created 3 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | sdk/lib/async/future_impl.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of dart.async; 5 part of dart.async;
6 6
7 /// A type representing values that are either `Future<T>` or `T`. 7 /// A type representing values that are either `Future<T>` or `T`.
8 /// 8 ///
9 /// This class declaration is a public stand-in for an internal 9 /// This class declaration is a public stand-in for an internal
10 /// future-or-value generic type. References to this class are resolved to the 10 /// future-or-value generic type. References to this class are resolved to the
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 static Future<List<T>> wait<T>(Iterable<Future<T>> futures, 297 static Future<List<T>> wait<T>(Iterable<Future<T>> futures,
298 {bool eagerError: false, 298 {bool eagerError: false,
299 void cleanUp(T successValue)}) { 299 void cleanUp(T successValue)}) {
300 final _Future<List<T>> result = new _Future<List<T>>(); 300 final _Future<List<T>> result = new _Future<List<T>>();
301 List<T> values; // Collects the values. Set to null on error. 301 List<T> values; // Collects the values. Set to null on error.
302 int remaining = 0; // How many futures are we waiting for. 302 int remaining = 0; // How many futures are we waiting for.
303 var error; // The first error from a future. 303 var error; // The first error from a future.
304 StackTrace stackTrace; // The stackTrace that came with the error. 304 StackTrace stackTrace; // The stackTrace that came with the error.
305 305
306 // Handle an error from any of the futures. 306 // Handle an error from any of the futures.
307 void handleError(theError, theStackTrace) { 307 handleError(theError, theStackTrace) {
floitsch 2017/02/28 19:04:35 This looks like a temporary problem. The 'then' i
Jennifer Messerly 2017/02/28 19:23:31 sounds great! I'll add that TODO, does this look g
308 remaining--; 308 remaining--;
309 if (values != null) { 309 if (values != null) {
310 if (cleanUp != null) { 310 if (cleanUp != null) {
311 for (var value in values) { 311 for (var value in values) {
312 if (value != null) { 312 if (value != null) {
313 // Ensure errors from cleanUp are uncaught. 313 // Ensure errors from cleanUp are uncaught.
314 new Future.sync(() { cleanUp(value); }); 314 new Future.sync(() { cleanUp(value); });
315 } 315 }
316 } 316 }
317 } 317 }
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 if (replacement != null) { 820 if (replacement != null) {
821 error = _nonNullError(replacement.error); 821 error = _nonNullError(replacement.error);
822 stackTrace = replacement.stackTrace; 822 stackTrace = replacement.stackTrace;
823 } 823 }
824 result._completeError(error, stackTrace); 824 result._completeError(error, stackTrace);
825 } 825 }
826 826
827 /** Helper function that converts `null` to a [NullThrownError]. */ 827 /** Helper function that converts `null` to a [NullThrownError]. */
828 Object _nonNullError(Object error) => 828 Object _nonNullError(Object error) =>
829 (error != null) ? error : new NullThrownError(); 829 (error != null) ? error : new NullThrownError();
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/async/future_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698