OLD | NEW |
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 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 * the future returned by `then` will be completed with | 425 * the future returned by `then` will be completed with |
426 * the same result as the future returned by the callback. | 426 * the same result as the future returned by the callback. |
427 * | 427 * |
428 * If [onError] is not given, and this future completes with an error, | 428 * If [onError] is not given, and this future completes with an error, |
429 * the error is forwarded directly to the returned future. | 429 * the error is forwarded directly to the returned future. |
430 * | 430 * |
431 * In most cases, it is more readable to use [catchError] separately, possibly | 431 * In most cases, it is more readable to use [catchError] separately, possibly |
432 * with a `test` parameter, instead of handling both value and error in a | 432 * with a `test` parameter, instead of handling both value and error in a |
433 * single [then] call. | 433 * single [then] call. |
434 */ | 434 */ |
435 Future/*<S>*/ then/*<S>*/(/*=S*/ onValue(T value), { Function onError }); | 435 Future/*<S>*/ then/*<S>*/(onValue(T value), { Function onError }); |
436 | 436 |
437 /** | 437 /** |
438 * Handles errors emitted by this [Future]. | 438 * Handles errors emitted by this [Future]. |
439 * | 439 * |
440 * This is the asynchronous equivalent of a "catch" block. | 440 * This is the asynchronous equivalent of a "catch" block. |
441 * | 441 * |
442 * Returns a new [Future] that will be completed with either the result of | 442 * Returns a new [Future] that will be completed with either the result of |
443 * this future or the result of calling the `onError` callback. | 443 * this future or the result of calling the `onError` callback. |
444 * | 444 * |
445 * If this future completes with a value, | 445 * If this future completes with a value, |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
755 if (replacement != null) { | 755 if (replacement != null) { |
756 error = _nonNullError(replacement.error); | 756 error = _nonNullError(replacement.error); |
757 stackTrace = replacement.stackTrace; | 757 stackTrace = replacement.stackTrace; |
758 } | 758 } |
759 result._completeError(error, stackTrace); | 759 result._completeError(error, stackTrace); |
760 } | 760 } |
761 | 761 |
762 /** Helper function that converts `null` to a [NullThrownError]. */ | 762 /** Helper function that converts `null` to a [NullThrownError]. */ |
763 Object _nonNullError(Object error) => | 763 Object _nonNullError(Object error) => |
764 (error != null) ? error : new NullThrownError(); | 764 (error != null) ? error : new NullThrownError(); |
OLD | NEW |