Chromium Code Reviews| 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 db0e70ba29dabc3a7db8ebf0309ab4c568e2cdc2..643288ac6260dac369088e8d3da67e8de63cf5a2 100644 |
| --- a/pkg/stack_trace/lib/src/trace.dart |
| +++ b/pkg/stack_trace/lib/src/trace.dart |
| @@ -12,6 +12,8 @@ import 'lazy_trace.dart'; |
| final _terseRegExp = new RegExp(r"(-patch)?(/.*)?$"); |
| +final _firefoxTrace = new RegExp(r"^[.0-9A-Za-z_$]*@"); |
|
Bob Nystrom
2013/06/26 17:01:05
Document what this is for and an example of what t
nweiz
2013/06/26 20:08:01
Done.
|
| + |
| /// A stack trace, comprised of a list of stack frames. |
| class Trace implements StackTrace { |
| /// The stack frames that comprise this stack trace. |
| @@ -57,9 +59,29 @@ class Trace implements StackTrace { |
| /// Parses a string representation of a stack trace. |
| /// |
| - /// [trace] should be formatted in the same way as native stack traces. |
| - Trace.parse(String trace) |
| - : this(trace.trim().split("\n").map((line) => new Frame.parse(line))); |
| + /// [trace] should be formatted in the same way as a Dart VM or browser stack |
| + /// trace. |
| + factory Trace.parse(String trace) { |
| + if (trace.startsWith("Error\n")) return new Trace.parseV8(trace); |
| + if (trace.contains(_firefoxTrace)) return new Trace.parseFirefox(trace); |
| + |
| + // Default to parsing the stack trace as a VM trace. This is also hit on IE |
| + // and Safari, where the stack trace is just an empty string (issue 11257). |
| + return new Trace.parseVM(trace); |
| + } |
| + |
| + /// Parses a string representation of a Dart VM stack trace. |
| + Trace.parseVM(String trace) |
| + : this(trace.trim().split("\n").map((line) => new Frame.parseVM(line))); |
| + |
| + /// Parses a string representation of a Chrome/V8 stack trace. |
| + Trace.parseV8(String trace) |
| + : this(trace.split("\n").skip(1).map((line) => new Frame.parseV8(line))); |
| + |
| + /// Parses a string representation of a Firefox stack trace. |
| + Trace.parseFirefox(String trace) |
| + : this(trace.trim().split("\n") |
| + .map((line) => new Frame.parseFirefox(line))); |
| /// Returns a new [Trace] comprised of [frames]. |
| Trace(Iterable<Frame> frames) |