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

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

Issue 1576853003: Deprecate the ChainHandler typedef. (Closed) Base URL: git@github.com:dart-lang/stack_trace@master
Patch Set: . Created 4 years, 11 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
« no previous file with comments | « CHANGELOG.md ('k') | lib/src/stack_zone_specification.dart » ('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 import 'dart:math' as math; 9 import 'dart:math' as math;
10 10
11 import 'frame.dart'; 11 import 'frame.dart';
12 import 'stack_zone_specification.dart'; 12 import 'stack_zone_specification.dart';
13 import 'trace.dart'; 13 import 'trace.dart';
14 import 'utils.dart'; 14 import 'utils.dart';
15 15
16 /// A function that handles errors in the zone wrapped by [Chain.capture]. 16 /// A function that handles errors in the zone wrapped by [Chain.capture].
17 @Deprecated("Will be removed in stack_trace 2.0.0.")
17 typedef void ChainHandler(error, Chain chain); 18 typedef void ChainHandler(error, Chain chain);
18 19
19 /// A chain of stack traces. 20 /// A chain of stack traces.
20 /// 21 ///
21 /// A stack chain is a collection of one or more stack traces that collectively 22 /// A stack chain is a collection of one or more stack traces that collectively
22 /// represent the path from [main] through nested function calls to a particular 23 /// represent the path from [main] through nested function calls to a particular
23 /// code location, usually where an error was thrown. Multiple stack traces are 24 /// code location, usually where an error was thrown. Multiple stack traces are
24 /// necessary when using asynchronous functions, since the program's stack is 25 /// necessary when using asynchronous functions, since the program's stack is
25 /// reset before each asynchronous callback is run. 26 /// reset before each asynchronous callback is run.
26 /// 27 ///
(...skipping 29 matching lines...) Expand all
56 /// error. Note that if [callback] produces multiple unhandled errors, 57 /// error. Note that if [callback] produces multiple unhandled errors,
57 /// [onError] may be called more than once. If [onError] isn't passed, the 58 /// [onError] may be called more than once. If [onError] isn't passed, the
58 /// parent Zone's `unhandledErrorHandler` will be called with the error and 59 /// parent Zone's `unhandledErrorHandler` will be called with the error and
59 /// its chain. 60 /// its chain.
60 /// 61 ///
61 /// Note that even if [onError] isn't passed, this zone will still be an error 62 /// Note that even if [onError] isn't passed, this zone will still be an error
62 /// zone. This means that any errors that would cross the zone boundary are 63 /// zone. This means that any errors that would cross the zone boundary are
63 /// considered unhandled. 64 /// considered unhandled.
64 /// 65 ///
65 /// If [callback] returns a value, it will be returned by [capture] as well. 66 /// If [callback] returns a value, it will be returned by [capture] as well.
66 static capture(callback(), {ChainHandler onError}) { 67 static capture(callback(), {void onError(error, Chain chain)}) {
67 var spec = new StackZoneSpecification(onError); 68 var spec = new StackZoneSpecification(onError);
68 return runZoned(() { 69 return runZoned(() {
69 try { 70 try {
70 return callback(); 71 return callback();
71 } catch (error, stackTrace) { 72 } catch (error, stackTrace) {
72 // TODO(nweiz): Don't special-case this when issue 19566 is fixed. 73 // TODO(nweiz): Don't special-case this when issue 19566 is fixed.
73 return Zone.current.handleUncaughtError(error, stackTrace); 74 return Zone.current.handleUncaughtError(error, stackTrace);
74 } 75 }
75 }, zoneSpecification: spec.toSpec(), zoneValues: { 76 }, zoneSpecification: spec.toSpec(), zoneValues: {
76 #stack_trace.stack_zone.spec: spec 77 #stack_trace.stack_zone.spec: spec
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 188
188 // Don't call out to [Trace.toString] here because that doesn't ensure that 189 // Don't call out to [Trace.toString] here because that doesn't ensure that
189 // padding is consistent across all traces. 190 // padding is consistent across all traces.
190 return traces.map((trace) { 191 return traces.map((trace) {
191 return trace.frames.map((frame) { 192 return trace.frames.map((frame) {
192 return '${padRight(frame.location, longest)} ${frame.member}\n'; 193 return '${padRight(frame.location, longest)} ${frame.member}\n';
193 }).join(); 194 }).join();
194 }).join(chainGap); 195 }).join(chainGap);
195 } 196 }
196 } 197 }
OLDNEW
« no previous file with comments | « CHANGELOG.md ('k') | lib/src/stack_zone_specification.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698