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

Side by Side Diff: pkg/stack_trace/test/chain_test.dart

Issue 232123003: Properly handle errors thrown in [Chain.capture]'s [onError] handler. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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/lib/src/stack_zone_specification.dart ('k') | no next file » | 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 chain_test; 5 library chain_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:path/path.dart' as p; 9 import 'package:path/path.dart' as p;
10 import 'package:stack_trace/stack_trace.dart'; 10 import 'package:stack_trace/stack_trace.dart';
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 } else { 100 } else {
101 expect(error, equals('second error')); 101 expect(error, equals('second error'));
102 expect(chain.traces[1].frames, 102 expect(chain.traces[1].frames,
103 contains(frameMember(startsWith('inPeriodicTimer')))); 103 contains(frameMember(startsWith('inPeriodicTimer'))));
104 completer.complete(); 104 completer.complete();
105 } 105 }
106 }); 106 });
107 107
108 return completer.future; 108 return completer.future;
109 }); 109 });
110
111 test('and relays them to the parent zone', () {
112 var completer = new Completer();
113
114 runZoned(() {
115 Chain.capture(() {
116 inMicrotask(() => throw 'error');
117 }, onError: (error, chain) {
118 expect(error, equals('error'));
119 expect(chain.traces[1].frames,
120 contains(frameMember(startsWith('inMicrotask'))));
121 throw error;
122 });
123 }, onError: (error, chain) {
124 expect(error, equals('error'));
125 expect(chain, new isInstanceOf<Chain>());
126 expect(chain.traces[1].frames,
127 contains(frameMember(startsWith('inMicrotask'))));
128 completer.complete();
129 });
130
131 return completer.future;
132 });
110 }); 133 });
111 134
112 test('capture() without onError passes exceptions to parent zone', () { 135 test('capture() without onError passes exceptions to parent zone', () {
113 var completer = new Completer(); 136 var completer = new Completer();
114 137
115 runZoned(() { 138 runZoned(() {
116 Chain.capture(() => inMicrotask(() => throw 'error')); 139 Chain.capture(() => inMicrotask(() => throw 'error'));
117 }, onError: (error, chain) { 140 }, onError: (error, chain) {
118 expect(error, equals('error')); 141 expect(error, equals('error'));
119 expect(chain, new isInstanceOf<Chain>()); 142 expect(chain, new isInstanceOf<Chain>());
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 /// 710 ///
688 /// [callback] is expected to throw the string `"error"`. 711 /// [callback] is expected to throw the string `"error"`.
689 Future<Chain> captureFuture(callback()) { 712 Future<Chain> captureFuture(callback()) {
690 var completer = new Completer<Chain>(); 713 var completer = new Completer<Chain>();
691 Chain.capture(callback, onError: (error, chain) { 714 Chain.capture(callback, onError: (error, chain) {
692 expect(error, equals('error')); 715 expect(error, equals('error'));
693 completer.complete(chain); 716 completer.complete(chain);
694 }); 717 });
695 return completer.future; 718 return completer.future;
696 } 719 }
OLDNEW
« no previous file with comments | « pkg/stack_trace/lib/src/stack_zone_specification.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698