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

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

Issue 2311923002: Don't propagate synchronous Future.wait errors immediately. (Closed)
Patch Set: Add test. Created 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | tests/lib/async/future_test.dart » ('j') | tests/lib/async/future_test.dart » ('J')
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 /** 7 /**
8 * An object representing a delayed computation. 8 * An object representing a delayed computation.
9 * 9 *
10 * A [Future] is used to represent a potential value, or error, 10 * A [Future] is used to represent a potential value, or error,
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 remaining++; 315 remaining++;
316 } 316 }
317 if (remaining == 0) { 317 if (remaining == 0) {
318 return new Future.value(const []); 318 return new Future.value(const []);
319 } 319 }
320 values = new List/*<T>*/(remaining); 320 values = new List/*<T>*/(remaining);
321 } catch (e, st) { 321 } catch (e, st) {
322 // The error must have been thrown while iterating over the futures 322 // The error must have been thrown while iterating over the futures
323 // list, or while installing a callback handler on the future. 323 // list, or while installing a callback handler on the future.
324 if (remaining == 0 || eagerError) { 324 if (remaining == 0 || eagerError) {
325 // Just complete the error immediately. 325 // Throw a new Future.error.
326 result._completeError(e, st); 326 // Don't just complete the existing `_Future` since that would propagate
Lasse Reichstein Nielsen 2016/09/06 09:53:27 Drop this comment. If you used _asyncCompleteError
floitsch 2016/09/06 09:57:15 Done.
327 // the error too eagerly, not giving the callers time to install
328 // error handlers.
329 return new Future.error(e, st);
327 } else { 330 } else {
328 // Don't allocate a list for values, thus indicating that there was an 331 // Don't allocate a list for values, thus indicating that there was an
329 // error. 332 // error.
330 // Set error to the caught exception. 333 // Set error to the caught exception.
331 error = e; 334 error = e;
332 stackTrace = st; 335 stackTrace = st;
333 } 336 }
334 } 337 }
335 return result; 338 return result;
336 } 339 }
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 if (replacement != null) { 778 if (replacement != null) {
776 error = _nonNullError(replacement.error); 779 error = _nonNullError(replacement.error);
777 stackTrace = replacement.stackTrace; 780 stackTrace = replacement.stackTrace;
778 } 781 }
779 result._completeError(error, stackTrace); 782 result._completeError(error, stackTrace);
780 } 783 }
781 784
782 /** Helper function that converts `null` to a [NullThrownError]. */ 785 /** Helper function that converts `null` to a [NullThrownError]. */
783 Object _nonNullError(Object error) => 786 Object _nonNullError(Object error) =>
784 (error != null) ? error : new NullThrownError(); 787 (error != null) ? error : new NullThrownError();
OLDNEW
« no previous file with comments | « no previous file | tests/lib/async/future_test.dart » ('j') | tests/lib/async/future_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698