Adds a console formatter for Error objects. So typing a expression in the
authortimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 16 Apr 2008 21:46:48 +0000 (21:46 +0000)
committertimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 16 Apr 2008 21:46:48 +0000 (21:46 +0000)
console that ends in an exception will print meaningful info. Also calling
console.{log,error,warn,info} with an error object will output nicely.

Reviewed by Adam Roben.

* page/inspector/Console.js:
(WebInspector.Console.prototype._formaterror): Added. Formats an error
object by showing it like other exceptions, with a clickable file URL.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@31966 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/page/inspector/Console.js

index dbbffbb..907c9f2 100644 (file)
@@ -1,5 +1,17 @@
 2008-04-16  Timothy Hatcher  <timothy@apple.com>
 
+        Adds a console formatter for Error objects. So typing a expression in the
+        console that ends in an exception will print meaningful info. Also calling
+        console.{log,error,warn,info} with an error object will output nicely.
+
+        Reviewed by Adam Roben.
+
+        * page/inspector/Console.js:
+        (WebInspector.Console.prototype._formaterror): Added. Formats an error
+        object by showing it like other exceptions, with a clickable file URL.
+
+2008-04-16  Timothy Hatcher  <timothy@apple.com>
+
         Refactors code that updates the errors and warnings count in the
         resources sidebar so other functions can easily trigger updates.
 
index 39cd2ad..d41a8b0 100644 (file)
@@ -410,6 +410,25 @@ WebInspector.Console.prototype = {
     {
         elem.appendChild(document.createTextNode(Object.describe(obj)));
     },
+
+    _formaterror: function(obj, elem)
+    {
+        elem.appendChild(document.createTextNode(obj.name + ": " + obj.message + " "));
+
+        if (obj.sourceURL) {
+            var urlElement = document.createElement("a");
+            urlElement.className = "console-message-url webkit-html-resource-link";
+            urlElement.href = obj.sourceURL;
+            urlElement.lineNumber = obj.line;
+
+            if (obj.line > 0)
+                urlElement.textContent = WebInspector.UIString("%s (line %d)", obj.sourceURL, obj.line);
+            else
+                urlElement.textContent = obj.sourceURL;
+
+            elem.appendChild(urlElement);
+        }
+    },
 }
 
 WebInspector.Console.prototype.__proto__ = WebInspector.View.prototype;