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

Unified Diff: pkg/stack_trace/lib/src/trace.dart

Issue 23159007: Properly parse V8 stack traces that contain the exception description. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/stack_trace/test/trace_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 863d64ef72a653c9232a50e361bf4391b78ca60f..4aea96023a73d808645b843e3a7610a66aa7ce27 100644
--- a/pkg/stack_trace/lib/src/trace.dart
+++ b/pkg/stack_trace/lib/src/trace.dart
@@ -14,6 +14,14 @@ import 'vm_trace.dart';
final _terseRegExp = new RegExp(r"(-patch)?(/.*)?$");
+/// A RegExp to match V8's stack traces.
+///
+/// V8's traces start with a line that's either just "Error" or else is a
+/// description of the exception that occurred. That description can be multiple
+/// lines, so we just look for any line other than the first that begins with
+/// four spaces and "at".
+final _v8Trace = new RegExp(r"\n at ");
+
/// A RegExp to match Firefox's stack traces.
///
/// Firefox's trace frames start with the name of the function in which the
@@ -74,7 +82,7 @@ class Trace implements StackTrace {
factory Trace.parse(String trace) {
try {
if (trace.isEmpty) return new Trace(<Frame>[]);
- if (trace.startsWith("Error\n")) return new Trace.parseV8(trace);
+ if (trace.contains(_v8Trace)) return new Trace.parseV8(trace);
if (trace.contains(_firefoxTrace)) return new Trace.parseFirefox(trace);
if (trace.contains(_friendlyTrace)) return new Trace.parseFriendly(trace);
@@ -93,7 +101,12 @@ class Trace implements StackTrace {
/// 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)));
+ : this(trace.split("\n").skip(1)
+ // It's possible that an Exception's description contains a line that
+ // looks like a V8 trace line, which will screw this up.
+ // Unfortunately, that's impossible to detect.
+ .skipWhile((line) => !line.startsWith(" at "))
+ .map((line) => new Frame.parseV8(line)));
/// Parses a string representation of a Firefox stack trace.
Trace.parseFirefox(String trace)
« no previous file with comments | « no previous file | pkg/stack_trace/test/trace_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698