| 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 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 * and the returned future completes with the same error and stack trace | 452 * and the returned future completes with the same error and stack trace |
| 453 * as this future. | 453 * as this future. |
| 454 * | 454 * |
| 455 * If `test` returns `true`, | 455 * If `test` returns `true`, |
| 456 * [onError] is called with the error and possibly stack trace, | 456 * [onError] is called with the error and possibly stack trace, |
| 457 * and the returned future is completed with the result of this call | 457 * and the returned future is completed with the result of this call |
| 458 * in exactly the same way as for [then]'s `onError`. | 458 * in exactly the same way as for [then]'s `onError`. |
| 459 * | 459 * |
| 460 * If `test` is omitted, it defaults to a function that always returns true. | 460 * If `test` is omitted, it defaults to a function that always returns true. |
| 461 * The `test` function should not throw, but if it does, it is handled as | 461 * The `test` function should not throw, but if it does, it is handled as |
| 462 * if the the `onError` function had thrown. | 462 * if the `onError` function had thrown. |
| 463 * | 463 * |
| 464 * Example: | 464 * Example: |
| 465 * | 465 * |
| 466 * foo | 466 * foo |
| 467 * .catchError(..., test: (e) => e is ArgumentError) | 467 * .catchError(..., test: (e) => e is ArgumentError) |
| 468 * .catchError(..., test: (e) => e is NoSuchMethodError) | 468 * .catchError(..., test: (e) => e is NoSuchMethodError) |
| 469 * .then((v) { ... }); | 469 * .then((v) { ... }); |
| 470 * | 470 * |
| 471 * This method is equivalent to: | 471 * This method is equivalent to: |
| 472 * | 472 * |
| (...skipping 282 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 |