| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 import 'dart:async'; | 5 import 'dart:async'; |
| 6 import 'dart:collection'; | 6 import 'dart:collection'; |
| 7 import 'dart:math' as math; | 7 import 'dart:math' as math; |
| 8 | 8 |
| 9 import 'frame.dart'; | 9 import 'frame.dart'; |
| 10 import 'stack_zone_specification.dart'; | 10 import 'stack_zone_specification.dart'; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 /// error. Note that if [callback] produces multiple unhandled errors, | 61 /// error. Note that if [callback] produces multiple unhandled errors, |
| 62 /// [onError] may be called more than once. If [onError] isn't passed, the | 62 /// [onError] may be called more than once. If [onError] isn't passed, the |
| 63 /// parent Zone's `unhandledErrorHandler` will be called with the error and | 63 /// parent Zone's `unhandledErrorHandler` will be called with the error and |
| 64 /// its chain. | 64 /// its chain. |
| 65 /// | 65 /// |
| 66 /// Note that even if [onError] isn't passed, this zone will still be an error | 66 /// Note that even if [onError] isn't passed, this zone will still be an error |
| 67 /// zone. This means that any errors that would cross the zone boundary are | 67 /// zone. This means that any errors that would cross the zone boundary are |
| 68 /// considered unhandled. | 68 /// considered unhandled. |
| 69 /// | 69 /// |
| 70 /// If [callback] returns a value, it will be returned by [capture] as well. | 70 /// If [callback] returns a value, it will be returned by [capture] as well. |
| 71 static /*=T*? capture/*<T>*/(/*=T*/ callback(), | 71 static /*=T*/ capture/*<T>*/(/*=T*/ callback(), |
| 72 {void onError(error, Chain chain), bool when: true}) { | 72 {void onError(error, Chain chain), bool when: true}) { |
| 73 if (!when) { | 73 if (!when) { |
| 74 var newOnError; | 74 var newOnError; |
| 75 if (onError != null) { | 75 if (onError != null) { |
| 76 newOnError = (error, stackTrace) { | 76 newOnError = (error, stackTrace) { |
| 77 onError(error, new Chain.forTrace(stackTrace)); | 77 onError(error, new Chain.forTrace(stackTrace)); |
| 78 }; | 78 }; |
| 79 } | 79 } |
| 80 | 80 |
| 81 return runZoned(callback, onError: newOnError); | 81 return runZoned(callback, onError: newOnError); |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 | 204 |
| 205 // Don't call out to [Trace.toString] here because that doesn't ensure that | 205 // Don't call out to [Trace.toString] here because that doesn't ensure that |
| 206 // padding is consistent across all traces. | 206 // padding is consistent across all traces. |
| 207 return traces.map((trace) { | 207 return traces.map((trace) { |
| 208 return trace.frames.map((frame) { | 208 return trace.frames.map((frame) { |
| 209 return '${padRight(frame.location, longest)} ${frame.member}\n'; | 209 return '${padRight(frame.location, longest)} ${frame.member}\n'; |
| 210 }).join(); | 210 }).join(); |
| 211 }).join(chainGap); | 211 }).join(chainGap); |
| 212 } | 212 } |
| 213 } | 213 } |
| OLD | NEW |