Index: pkg/stack_trace/lib/src/trace.dart |
diff --git a/pkg/stack_trace/lib/src/trace.dart b/pkg/stack_trace/lib/src/trace.dart |
index c3db43ecd0eb243f7d092f9ba2de1aaccded502c..88b9275182b64262268c3a2c6ba892ad99754e66 100644 |
--- a/pkg/stack_trace/lib/src/trace.dart |
+++ b/pkg/stack_trace/lib/src/trace.dart |
@@ -7,6 +7,7 @@ library trace; |
import 'dart:collection'; |
import 'dart:math' as math; |
+import 'chain.dart'; |
import 'frame.dart'; |
import 'lazy_trace.dart'; |
import 'utils.dart'; |
@@ -92,6 +93,7 @@ class Trace implements StackTrace { |
/// a [Trace], it will be returned as-is. |
factory Trace.from(StackTrace trace) { |
if (trace is Trace) return trace; |
+ if (trace is Chain) return trace.toTrace(); |
return new LazyTrace(() => new Trace.parse(trace.toString())); |
} |
@@ -172,9 +174,14 @@ class Trace implements StackTrace { |
.where((line) => line != '[native code]') |
.map((line) => new Frame.parseFirefox(line))); |
- /// Parses this package's a string representation of a stack trace. |
+ /// Parses this package's string representation of a stack trace. |
+ /// |
+ /// This also parses string representations of [Chain]s. They parse to the |
+ /// same trace that [Chain.toTrace] would return. |
Trace.parseFriendly(String trace) |
: this(trace.trim().split("\n") |
+ // Filter out asynchronous gaps from [Chain]s. |
+ .where((line) => !line.startsWith('=====')) |
.map((line) => new Frame.parseFriendly(line))); |
/// Returns a new [Trace] comprised of [frames]. |
@@ -191,10 +198,13 @@ class Trace implements StackTrace { |
/// Returns a terser version of [this]. |
/// |
/// This is accomplished by folding together multiple stack frames from the |
- /// core library, as in [foldFrames]. Remaining core library frames have their |
- /// libraries, "-patch" suffixes, and line numbers removed. |
+ /// core library or from this package, as in [foldFrames]. Remaining core |
+ /// library frames have their libraries, "-patch" suffixes, and line numbers |
+ /// removed. |
Trace get terse { |
- return new Trace(foldFrames((frame) => frame.isCore).frames.map((frame) { |
+ return new Trace(foldFrames((frame) { |
+ return frame.isCore || frame.package == 'stack_trace'; |
+ }).frames.map((frame) { |
if (!frame.isCore) return frame; |
var library = frame.library.replaceAll(_terseRegExp, ''); |
return new Frame(Uri.parse(library), null, null, frame.member); |