Revision: 21224
Author: [email protected]
Date: Fri May 9 13:14:09 2014 UTC
Log: Shorten autogenerated error message for functions only.
[email protected], Yang, [email protected]
BUG=v8:3019, chromium:331971
LOG=Y
Review URL: https://codereview.chromium.org/271733005
Patch from Andrey Adaykin <[email protected]>.
http://code.google.com/p/v8/source/detail?r=21224
Modified:
/branches/bleeding_edge/src/messages.js
/branches/bleeding_edge/test/mjsunit/error-tostring-omit.js
=======================================
--- /branches/bleeding_edge/src/messages.js Fri May 2 13:55:11 2014 UTC
+++ /branches/bleeding_edge/src/messages.js Fri May 9 13:14:09 2014 UTC
@@ -177,10 +177,6 @@
// 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";
@@ -200,10 +196,17 @@
function NoSideEffectToString(obj) {
if (IS_STRING(obj)) return obj;
if (IS_NUMBER(obj)) return %_NumberToString(obj);
- if (IS_BOOLEAN(obj)) return x ? 'true' : 'false';
+ if (IS_BOOLEAN(obj)) return obj ? 'true' : 'false';
if (IS_UNDEFINED(obj)) return 'undefined';
if (IS_NULL(obj)) return 'null';
- if (IS_FUNCTION(obj)) return %_CallFunction(obj, FunctionToString);
+ if (IS_FUNCTION(obj)) {
+ var str = %_CallFunction(obj, FunctionToString);
+ if (str.length > 128) {
+ str = %_SubString(str, 0, 111) + "...<omitted>..." +
+ %_SubString(str, str.length - 2, str.length);
+ }
+ return str;
+ }
if (IS_OBJECT(obj) && %GetDataProperty(obj, "toString") ===
ObjectToString) {
var constructor = %GetDataProperty(obj, "constructor");
if (typeof constructor == "function") {
=======================================
--- /branches/bleeding_edge/test/mjsunit/error-tostring-omit.js Fri Jan 31
16:52:17 2014 UTC
+++ /branches/bleeding_edge/test/mjsunit/error-tostring-omit.js Fri May 9
13:14:09 2014 UTC
@@ -37,23 +37,15 @@
"Nam accumsan dignissim turpis a turpis duis.";
}
+assertTrue(veryLongString().length > 256);
-var re = /omitted/;
-
-try {
- veryLongString.nonexistentMethod();
-} catch (e) {
- assertTrue(e.message.length < 350);
- // TODO(verwaest): Proper error message.
- // assertTrue(re.test(e.message));
-}
+var re = /...<omitted>.../;
try {
- veryLongString().nonexistentMethod();
+ Number.prototype.toFixed.call(veryLongString);
} catch (e) {
- assertTrue(e.message.length < 350);
- // TODO(verwaest): Proper error message.
- // assertTrue(re.test(e.message));
+ assertTrue(e.message.length < 256);
+ assertTrue(re.test(e.message));
}
try {
--
--
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/d/optout.