Change recursive error printing to just replace recursively
authorager@chromium.org <ager@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 21 Jan 2011 14:11:35 +0000 (14:11 +0000)
committerager@chromium.org <ager@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 21 Jan 2011 14:11:35 +0000 (14:11 +0000)
encountered error objects with the empty string. This actually does
match the Safari behaviour.

Review URL: http://codereview.chromium.org/6259010

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6430 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/messages.js
test/mjsunit/cyclic-error-to-string.js

index d654255..4a89647 100644 (file)
@@ -1033,19 +1033,16 @@ function errorToStringDetectCycle() {
 }
 
 function errorToString() {
-  // These helper functions are needed because access to properties on
+  // This helper function is needed because access to properties on
   // the builtins object do not work inside of a catch clause.
   function isCyclicErrorMarker(o) { return o === cyclic_error_marker; }
-  function isVisitedErrorsEmpty() { return visited_errors.length === 0; }
 
   try {
     return %_CallFunction(this, errorToStringDetectCycle);
   } catch(e) {
-    // Propagate cyclic_error_marker exception until all error
-    // formatting is finished and then return the empty string. Safari
-    // and Firefox also returns the empty string when converting a
-    // cyclic error to a string.
-    if (isCyclicErrorMarker(e) && isVisitedErrorsEmpty()) return '';
+    // If this error message was encountered already return the empty
+    // string for it instead of recursively formatting it.
+    if (isCyclicErrorMarker(e)) return '';
     else throw e;
   }
 }
index 7c43fc5..2502b53 100644 (file)
@@ -36,11 +36,11 @@ e.name = e;
 e.message = e;
 e.stack = e;
 e.arguments = e;
-assertEquals('', e + '');
+assertEquals('', e + '');
 
 e = new Error();
 e.name = [ e ];
 e.message = [ e ];
 e.stack = [ e ];
 e.arguments = [ e ];
-assertEquals('', e + '');
+assertEquals('', e + '');