Reviewers: rossberg,

Description:
Shorten autogenerated error message.

[email protected]
BUG=v8:3019

Please review this at https://codereview.chromium.org/88393002/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+31, -8 lines):
  M src/messages.js
  A + test/mjsunit/error-tostring-omit.js


Index: src/messages.js
diff --git a/src/messages.js b/src/messages.js
index 926f294ae870ee39d54b38fe34392b624d65bf31..e654623661409e67cb04135672e035092a2f7b0d 100644
--- a/src/messages.js
+++ b/src/messages.js
@@ -196,6 +196,10 @@ function FormatString(format, args) {
         // str is one of %0, %1, %2 or %3.
         try {
           str = NoSideEffectToString(args[arg_num]);
+          if (str.length > 256) {
+            str = %SubString(str, 0, 239) + "...<omitted>..." +
+                  %SubString(str, str.length - 2, str.length);
+          }
         } catch (e) {
           if (%IsJSModule(args[arg_num]))
             str = "module";
Index: test/mjsunit/error-tostring-omit.js
diff --git a/test/mjsunit/regress/regress-237617.js b/test/mjsunit/error-tostring-omit.js
similarity index 61%
copy from test/mjsunit/regress/regress-237617.js
copy to test/mjsunit/error-tostring-omit.js
index 7b7e50f247c7e4b29d2a4ba7892c280336ae04e6..ce7b2dc88e2d6be44015b704c5b697bf0d0da9e3 100644
--- a/test/mjsunit/regress/regress-237617.js
+++ b/test/mjsunit/error-tostring-omit.js
@@ -25,18 +25,37 @@
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

-"use strict"
+function veryLongString() {
+  return "Lorem ipsum dolor sit amet, consectetur adipiscing elit." +
+         "Nam vulputate metus est. Maecenas quis pellentesque eros," +
+         "ac mattis augue. Nam porta purus vitae tincidunt blandit." +
+         "Aliquam lacus dui, blandit id consectetur id, hendrerit ut" +
+         "felis. Class aptent taciti sociosqu ad litora torquent per" +
+         "conubia nostra, per inceptos himenaeos. Ut posuere eros et" +
+         "tempus luctus. Nullam condimentum aliquam odio, at dignissim" +
+         "augue tincidunt in. Nam mattis vitae mauris eget dictum." +
+         "Nam accumsan dignissim turpis a turpis duis.";
+}
+

-function f() {
-  throw new Error("test stack");
+var re = /omitted/;
+
+try {
+  veryLongString.nonexistentMethod();
+} catch (e) {
+  assertTrue(e.message.length < 350);
+  assertTrue(re.test(e.message));
 }

-var error_stack = "";
 try {
-  f.call(null);
+  veryLongString().nonexistentMethod();
 } catch (e) {
-  error_stack = e.stack;
+  assertTrue(e.message.length < 350);
+  assertTrue(re.test(e.message));
 }

-assertTrue(error_stack.indexOf("test stack") > 0);
-assertTrue(error_stack.indexOf("illegal") < 0);
+try {
+  throw Error(veryLongString());
+} catch (e) {
+  assertEquals(veryLongString(), e.message);
+}


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to