Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(343)

Side by Side Diff: pkg/stack_trace/lib/src/chain.dart

Issue 344953002: Properly handle synchronous errors in Chain.capture. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/stack_trace/CHANGELOG.md ('k') | pkg/stack_trace/pubspec.yaml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 library stack_trace.chain; 5 library stack_trace.chain;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import 'frame.dart'; 10 import 'frame.dart';
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 /// If [callback] returns a value, it will be returned by [capture] as well. 83 /// If [callback] returns a value, it will be returned by [capture] as well.
84 /// 84 ///
85 /// Currently, capturing stack chains doesn't work when using dart2js due to 85 /// Currently, capturing stack chains doesn't work when using dart2js due to
86 /// issues [15171] and [15105]. Stack chains reported on dart2js will contain 86 /// issues [15171] and [15105]. Stack chains reported on dart2js will contain
87 /// only one trace. 87 /// only one trace.
88 /// 88 ///
89 /// [15171]: https://code.google.com/p/dart/issues/detail?id=15171 89 /// [15171]: https://code.google.com/p/dart/issues/detail?id=15171
90 /// [15105]: https://code.google.com/p/dart/issues/detail?id=15105 90 /// [15105]: https://code.google.com/p/dart/issues/detail?id=15105
91 static capture(callback(), {ChainHandler onError}) { 91 static capture(callback(), {ChainHandler onError}) {
92 var spec = new StackZoneSpecification(onError); 92 var spec = new StackZoneSpecification(onError);
93 return runZoned(callback, zoneSpecification: spec.toSpec(), zoneValues: { 93 return runZoned(() {
94 try {
95 return callback();
96 } catch (error, stackTrace) {
97 // TODO(nweiz): Don't special-case this when issue 19566 is fixed.
98 return Zone.current.handleUncaughtError(error, stackTrace);
99 }
100 }, zoneSpecification: spec.toSpec(), zoneValues: {
94 #stack_trace.stack_zone.spec: spec 101 #stack_trace.stack_zone.spec: spec
95 }); 102 });
96 } 103 }
97 104
98 /// Ensures that any errors emitted by [futureOrStream] have the correct stack 105 /// Ensures that any errors emitted by [futureOrStream] have the correct stack
99 /// chain information associated with them. 106 /// chain information associated with them.
100 /// 107 ///
101 /// For the most part an error thrown within a [capture] zone will have the 108 /// For the most part an error thrown within a [capture] zone will have the
102 /// correct stack chain automatically associated with it. However, there are 109 /// correct stack chain automatically associated with it. However, there are
103 /// some cases where exceptions won't be automatically detected: any [Future] 110 /// some cases where exceptions won't be automatically detected: any [Future]
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 } 214 }
208 215
209 /// Converts [this] to a [Trace]. 216 /// Converts [this] to a [Trace].
210 /// 217 ///
211 /// The trace version of a chain is just the concatenation of all the traces 218 /// The trace version of a chain is just the concatenation of all the traces
212 /// in the chain. 219 /// in the chain.
213 Trace toTrace() => new Trace(flatten(traces.map((trace) => trace.frames))); 220 Trace toTrace() => new Trace(flatten(traces.map((trace) => trace.frames)));
214 221
215 String toString() => traces.join(_GAP); 222 String toString() => traces.join(_GAP);
216 } 223 }
OLDNEW
« no previous file with comments | « pkg/stack_trace/CHANGELOG.md ('k') | pkg/stack_trace/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698