Commit bd93673f authored by yangguo@chromium.org's avatar yangguo@chromium.org

Shorten autogenerated error message for functions only.

R=yangguo@chromium.org, Yang, rossberg@chromium.org
BUG=v8:3019, chromium:331971
LOG=Y

Review URL: https://codereview.chromium.org/271733005

Patch from Andrey Adaykin <aandrey@chromium.org>.

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@21224 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 3fa6100e
......@@ -177,10 +177,6 @@ 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";
......@@ -200,10 +196,17 @@ function FormatString(format, args) {
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") {
......
......@@ -37,23 +37,15 @@ function veryLongString() {
"Nam accumsan dignissim turpis a turpis duis.";
}
assertTrue(veryLongString().length > 256);
var re = /omitted/;
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));
}
try {
veryLongString().nonexistentMethod();
} 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 {
......
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