Title: [202025] trunk/Source/WebInspectorUI
Revision
202025
Author
[email protected]
Date
2016-06-13 21:33:06 -0700 (Mon, 13 Jun 2016)

Log Message

Web Inspector: Show Exception Stack in UncaughtExceptionReporter view
https://bugs.webkit.org/show_bug.cgi?id=158657
<rdar://problem/26754441>

Patch by Joseph Pecoraro <[email protected]> on 2016-06-13
Reviewed by Darin Adler.

* UserInterface/Debug/UncaughtExceptionReporter.css:
(.uncaught-exception-sheet li):
Make newlines significant.

* UserInterface/Debug/UncaughtExceptionReporter.js:
(unblockEventHandlers):
(handleError):
(handleLinkClick):
(formattedEntry):
Format the exception and a possible stack with a bit of sanitizing.

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (202024 => 202025)


--- trunk/Source/WebInspectorUI/ChangeLog	2016-06-14 04:03:02 UTC (rev 202024)
+++ trunk/Source/WebInspectorUI/ChangeLog	2016-06-14 04:33:06 UTC (rev 202025)
@@ -1,3 +1,22 @@
+2016-06-13  Joseph Pecoraro  <[email protected]>
+
+        Web Inspector: Show Exception Stack in UncaughtExceptionReporter view
+        https://bugs.webkit.org/show_bug.cgi?id=158657
+        <rdar://problem/26754441>
+
+        Reviewed by Darin Adler.
+
+        * UserInterface/Debug/UncaughtExceptionReporter.css:
+        (.uncaught-exception-sheet li):
+        Make newlines significant.
+
+        * UserInterface/Debug/UncaughtExceptionReporter.js:
+        (unblockEventHandlers):
+        (handleError):
+        (handleLinkClick):
+        (formattedEntry):
+        Format the exception and a possible stack with a bit of sanitizing.
+
 2016-06-13  Matt Baker  <[email protected]>
 
         Web Inspector: Filter Records not applying to new records

Modified: trunk/Source/WebInspectorUI/UserInterface/Debug/UncaughtExceptionReporter.css (202024 => 202025)


--- trunk/Source/WebInspectorUI/UserInterface/Debug/UncaughtExceptionReporter.css	2016-06-14 04:03:02 UTC (rev 202024)
+++ trunk/Source/WebInspectorUI/UserInterface/Debug/UncaughtExceptionReporter.css	2016-06-14 04:33:06 UTC (rev 202025)
@@ -110,4 +110,5 @@
     margin-bottom: 20px;
     word-break: break-word;
     -webkit-user-select: text;
+    white-space: pre;
 }

Modified: trunk/Source/WebInspectorUI/UserInterface/Debug/UncaughtExceptionReporter.js (202024 => 202025)


--- trunk/Source/WebInspectorUI/UserInterface/Debug/UncaughtExceptionReporter.js	2016-06-14 04:03:02 UTC (rev 202024)
+++ trunk/Source/WebInspectorUI/UserInterface/Debug/UncaughtExceptionReporter.js	2016-06-14 04:33:06 UTC (rev 202025)
@@ -56,6 +56,7 @@
         url: parseURL(error.sourceURL).lastPathComponent,
         lineNumber: error.line,
         columnNumber: error.column,
+        stack: error.stack,
     });
 }
 
@@ -65,6 +66,7 @@
         url: parseURL(event.filename).lastPathComponent,
         lineNumber: event.lineno,
         columnNumber: event.colno,
+        stack: typeof event.error === "object" ? event.error.stack : null,
     });
 }
 
@@ -147,12 +149,31 @@
             dismissErrorSheet();
     }
 
+    function formattedEntry(entry) {
+        let message = `${entry.message} (at ${entry.url}:${entry.lineNumber}:${entry.columnNumber})`;
+        if (!entry.stack)
+            return message;
+
+        const indent = "    ";
+        let results = [];
+        let lines = entry.stack.split(/\n/g);
+        for (let line of lines) {
+            let atIndex = line.indexOf("@");
+            let slashIndex = Math.max(line.lastIndexOf("/"), atIndex);
+            let functionName = line.substring(0, atIndex) || "?";
+            let location = line.substring(slashIndex + 1, line.length);
+            results.push(`${indent}${functionName} @ ${location}`);
+        }
+
+        return message + "\n" + results.join("\n");
+    }
+
     let inspectedPageURL = null;
     try {
         inspectedPageURL = WebInspector.frameResourceManager.mainFrame.url;
     } catch (e) { }
 
-    let formattedErrorDetails = window.__uncaughtExceptions.map((entry) => `${entry.message} (at ${entry.url}:${entry.lineNumber}:${entry.columnNumber})`);
+    let formattedErrorDetails = window.__uncaughtExceptions.map((entry) => formattedEntry(entry));
     let detailsForBugReport = formattedErrorDetails.map((line) => ` - ${line}`).join("\n");
     let encodedBugDescription = encodeURIComponent(`-------
 Auto-generated details:
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to