Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(571)

Unified Diff: src/messages.js

Issue 271733005: Shorten autogenerated error message for functions only. (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/mjsunit/error-tostring-omit.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/messages.js
diff --git a/src/messages.js b/src/messages.js
index 1965da104e33106d07fcf2de881f72363c9cddda..6c50b1badc418dd315b0097e523e7dce95b07203 100644
--- a/src/messages.js
+++ b/src/messages.js
@@ -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") {
« no previous file with comments | « no previous file | test/mjsunit/error-tostring-omit.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698