Commit bb9c9fe9 authored by ager@chromium.org's avatar ager@chromium.org

Change recursive error printing to just replace recursively

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
parent 7e423ec8
...@@ -1033,19 +1033,16 @@ function errorToStringDetectCycle() { ...@@ -1033,19 +1033,16 @@ function errorToStringDetectCycle() {
} }
function errorToString() { 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. // the builtins object do not work inside of a catch clause.
function isCyclicErrorMarker(o) { return o === cyclic_error_marker; } function isCyclicErrorMarker(o) { return o === cyclic_error_marker; }
function isVisitedErrorsEmpty() { return visited_errors.length === 0; }
try { try {
return %_CallFunction(this, errorToStringDetectCycle); return %_CallFunction(this, errorToStringDetectCycle);
} catch(e) { } catch(e) {
// Propagate cyclic_error_marker exception until all error // If this error message was encountered already return the empty
// formatting is finished and then return the empty string. Safari // string for it instead of recursively formatting it.
// and Firefox also returns the empty string when converting a if (isCyclicErrorMarker(e)) return '';
// cyclic error to a string.
if (isCyclicErrorMarker(e) && isVisitedErrorsEmpty()) return '';
else throw e; else throw e;
} }
} }
......
...@@ -36,11 +36,11 @@ e.name = e; ...@@ -36,11 +36,11 @@ e.name = e;
e.message = e; e.message = e;
e.stack = e; e.stack = e;
e.arguments = e; e.arguments = e;
assertEquals('', e + ''); assertEquals(': ', e + '');
e = new Error(); e = new Error();
e.name = [ e ]; e.name = [ e ];
e.message = [ e ]; e.message = [ e ];
e.stack = [ e ]; e.stack = [ e ];
e.arguments = [ e ]; e.arguments = [ e ];
assertEquals('', e + ''); assertEquals(': ', e + '');
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment