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:math' as math; | 6 import 'dart:math' as math; |
7 | 7 |
8 import 'frame.dart'; | 8 import 'frame.dart'; |
9 import 'lazy_chain.dart'; | 9 import 'lazy_chain.dart'; |
10 import 'stack_zone_specification.dart'; | 10 import 'stack_zone_specification.dart'; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 | 86 |
87 return runZoned(callback, onError: newOnError); | 87 return runZoned(callback, onError: newOnError); |
88 } | 88 } |
89 | 89 |
90 var spec = new StackZoneSpecification(onError); | 90 var spec = new StackZoneSpecification(onError); |
91 return runZoned(() { | 91 return runZoned(() { |
92 try { | 92 try { |
93 return callback(); | 93 return callback(); |
94 } catch (error, stackTrace) { | 94 } catch (error, stackTrace) { |
95 // TODO(nweiz): Don't special-case this when issue 19566 is fixed. | 95 // TODO(nweiz): Don't special-case this when issue 19566 is fixed. |
96 return Zone.current.handleUncaughtError(error, stackTrace); | 96 Zone.current.handleUncaughtError(error, stackTrace); |
| 97 return null; |
97 } | 98 } |
98 }, | 99 }, |
99 zoneSpecification: spec.toSpec(), | 100 zoneSpecification: spec.toSpec(), |
100 zoneValues: {_specKey: spec, StackZoneSpecification.disableKey: false}); | 101 zoneValues: {_specKey: spec, StackZoneSpecification.disableKey: false}); |
101 } | 102 } |
102 | 103 |
103 /// If [when] is `true` and this is called within a [Chain.capture] zone, runs | 104 /// If [when] is `true` and this is called within a [Chain.capture] zone, runs |
104 /// [callback] in a [Zone] in which chain capturing is disabled. | 105 /// [callback] in a [Zone] in which chain capturing is disabled. |
105 /// | 106 /// |
106 /// If [callback] returns a value, it will be returned by [disable] as well. | 107 /// If [callback] returns a value, it will be returned by [disable] as well. |
107 static/*=T*/ disable/*<T>*/(/*=T*/ callback(), {bool when: true}) { | 108 static T disable<T>(T callback(), {bool when: true}) { |
108 var zoneValues = | 109 var zoneValues = |
109 when ? {_specKey: null, StackZoneSpecification.disableKey: true} : null; | 110 when ? {_specKey: null, StackZoneSpecification.disableKey: true} : null; |
110 | 111 |
111 return runZoned(callback, zoneValues: zoneValues); | 112 return runZoned(callback, zoneValues: zoneValues); |
112 } | 113 } |
113 | 114 |
114 /// Returns [futureOrStream] unmodified. | 115 /// Returns [futureOrStream] unmodified. |
115 /// | 116 /// |
116 /// Prior to Dart 1.7, this was necessary to ensure that stack traces for | 117 /// Prior to Dart 1.7, this was necessary to ensure that stack traces for |
117 /// exceptions reported with [Completer.completeError] and | 118 /// exceptions reported with [Completer.completeError] and |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 | 242 |
242 // Don't call out to [Trace.toString] here because that doesn't ensure that | 243 // Don't call out to [Trace.toString] here because that doesn't ensure that |
243 // padding is consistent across all traces. | 244 // padding is consistent across all traces. |
244 return traces.map((trace) { | 245 return traces.map((trace) { |
245 return trace.frames.map((frame) { | 246 return trace.frames.map((frame) { |
246 return '${frame.location.padRight(longest)} ${frame.member}\n'; | 247 return '${frame.location.padRight(longest)} ${frame.member}\n'; |
247 }).join(); | 248 }).join(); |
248 }).join(chainGap); | 249 }).join(chainGap); |
249 } | 250 } |
250 } | 251 } |
OLD | NEW |