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 /** Runs user code and takes actions depending on success or failure. */ | 7 /** Runs user code and takes actions depending on success or failure. */ |
8 _runUserCode( | 8 _runUserCode<T>( |
9 userCode(), onSuccess(value), onError(error, StackTrace stackTrace)) { | 9 T userCode(), onSuccess(T value), onError(error, StackTrace stackTrace)) { |
10 try { | 10 try { |
11 onSuccess(userCode()); | 11 onSuccess(userCode()); |
12 } catch (e, s) { | 12 } catch (e, s) { |
13 AsyncError replacement = Zone.current.errorCallback(e, s); | 13 AsyncError replacement = Zone.current.errorCallback(e, s); |
14 if (replacement == null) { | 14 if (replacement == null) { |
15 onError(e, s); | 15 onError(e, s); |
16 } else { | 16 } else { |
17 var error = _nonNullError(replacement.error); | 17 var error = _nonNullError(replacement.error); |
18 var stackTrace = replacement.stackTrace; | 18 var stackTrace = replacement.stackTrace; |
19 onError(error, stackTrace); | 19 onError(error, stackTrace); |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 _addErrorWithReplacement(sink, e, s); | 476 _addErrorWithReplacement(sink, e, s); |
477 return null; | 477 return null; |
478 } | 478 } |
479 if (!isEqual) { | 479 if (!isEqual) { |
480 sink._add(inputEvent); | 480 sink._add(inputEvent); |
481 _previous = inputEvent; | 481 _previous = inputEvent; |
482 } | 482 } |
483 } | 483 } |
484 } | 484 } |
485 } | 485 } |
OLD | NEW |