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 /** The onValue and onError handlers return either a value or a future */ | 7 /** The onValue and onError handlers return either a value or a future */ |
8 typedef dynamic/*T|Future<T>*/ _FutureOnValue<S, T>(S value); | 8 typedef dynamic/*T|Future<T>*/ _FutureOnValue<S, T>(S value); |
9 /** Test used by [Future.catchError] to handle skip some errors. */ | 9 /** Test used by [Future.catchError] to handle skip some errors. */ |
10 typedef bool _FutureErrorTest(var error); | 10 typedef bool _FutureErrorTest(var error); |
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 var originalSource = source; | 620 var originalSource = source; |
621 listenerValueOrError = completeResult.then((_) => originalSource); | 621 listenerValueOrError = completeResult.then((_) => originalSource); |
622 listenerHasError = false; | 622 listenerHasError = false; |
623 } | 623 } |
624 } | 624 } |
625 | 625 |
626 void handleValueCallback() { | 626 void handleValueCallback() { |
627 try { | 627 try { |
628 listenerValueOrError = listener.handleValue(sourceResult); | 628 listenerValueOrError = listener.handleValue(sourceResult); |
629 } catch (e, s) { | 629 } catch (e, s) { |
630 if (identical(source._error.error, e)) { | 630 listenerValueOrError = new AsyncError(e, s); |
631 listenerValueOrError = source._error; | |
632 } else { | |
633 listenerValueOrError = new AsyncError(e, s); | |
634 } | |
635 listenerHasError = true; | 631 listenerHasError = true; |
636 } | 632 } |
637 } | 633 } |
638 | 634 |
639 void handleError() { | 635 void handleError() { |
640 try { | 636 try { |
641 AsyncError asyncError = source._error; | 637 AsyncError asyncError = source._error; |
642 if (listener.matchesErrorTest(asyncError) && | 638 if (listener.matchesErrorTest(asyncError) && |
643 listener.hasErrorCallback) { | 639 listener.hasErrorCallback) { |
644 listenerValueOrError = listener.handleError(asyncError); | 640 listenerValueOrError = listener.handleError(asyncError); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
732 } | 728 } |
733 }, onError: (e, s) { | 729 }, onError: (e, s) { |
734 if (timer.isActive) { | 730 if (timer.isActive) { |
735 timer.cancel(); | 731 timer.cancel(); |
736 result._completeError(e, s); | 732 result._completeError(e, s); |
737 } | 733 } |
738 }); | 734 }); |
739 return result; | 735 return result; |
740 } | 736 } |
741 } | 737 } |
OLD | NEW |