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

Side by Side Diff: pkg/scheduled_test/lib/src/utils.dart

Issue 68493003: Ensure that errors have stack traces attached. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month 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
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 utils; 5 library utils;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:stack_trace/stack_trace.dart'; 9 import 'package:stack_trace/stack_trace.dart';
10 10
(...skipping 10 matching lines...) Expand all
21 if (other is! Pair) return false; 21 if (other is! Pair) return false;
22 return other.first == first && other.last == last; 22 return other.first == first && other.last == last;
23 } 23 }
24 24
25 int get hashCode => first.hashCode ^ last.hashCode; 25 int get hashCode => first.hashCode ^ last.hashCode;
26 } 26 }
27 27
28 /// Configures [future] so that its result (success or exception) is passed on 28 /// Configures [future] so that its result (success or exception) is passed on
29 /// to [completer]. 29 /// to [completer].
30 void chainToCompleter(Future future, Completer completer) { 30 void chainToCompleter(Future future, Completer completer) {
31 future.then((value) => completer.complete(value), 31 future.then(completer.complete, onError: completer.completeError);
32 onError: completer.completeError);
33 } 32 }
34 33
35 /// Prepends each line in [text] with [prefix]. If [firstPrefix] is passed, the 34 /// Prepends each line in [text] with [prefix]. If [firstPrefix] is passed, the
36 /// first line is prefixed with that instead. 35 /// first line is prefixed with that instead.
37 String prefixLines(String text, {String prefix: '| ', String firstPrefix}) { 36 String prefixLines(String text, {String prefix: '| ', String firstPrefix}) {
38 var lines = text.split('\n'); 37 var lines = text.split('\n');
39 if (firstPrefix == null) { 38 if (firstPrefix == null) {
40 return lines.map((line) => '$prefix$line').join('\n'); 39 return lines.map((line) => '$prefix$line').join('\n');
41 } 40 }
42 41
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 } 231 }
233 232
234 /// Returns a string representation of [trace] that has the core and test frames 233 /// Returns a string representation of [trace] that has the core and test frames
235 /// folded together. 234 /// folded together.
236 String terseTraceString(StackTrace trace) { 235 String terseTraceString(StackTrace trace) {
237 return new Trace.from(trace).terse.foldFrames((frame) { 236 return new Trace.from(trace).terse.foldFrames((frame) {
238 return frame.package == 'scheduled_test' || frame.package == 'unittest' || 237 return frame.package == 'scheduled_test' || frame.package == 'unittest' ||
239 frame.isCore; 238 frame.isCore;
240 }).toString().trim(); 239 }).toString().trim();
241 } 240 }
OLDNEW
« no previous file with comments | « pkg/scheduled_test/lib/src/scheduled_server/safe_http_server.dart ('k') | pkg/scheduled_test/test/utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698