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

Unified Diff: src/messages.js

Issue 21761002: Improve internal stringifcation for custom Error objects. (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Better. Created 7 years, 5 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/cctest/test-api.cc » ('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 b586d24882b02a5e46528efef9dded04ac510540..1561e4abab0011d2dc704e3129ebc7b9255b8dcc 100644
--- a/src/messages.js
+++ b/src/messages.js
@@ -228,7 +228,11 @@ function NoSideEffectToString(obj) {
}
}
}
- if (IsNativeErrorObject(obj)) return %_CallFunction(obj, ErrorToString);
+ var objToString = GetPropertyWithoutInvokingMonkeyGetters(obj, "toString");
Michael Starzinger 2013/08/02 12:16:02 Yep, better, final nit: Can we move this into the
+ if (IsNativeErrorObject(obj) ||
+ (obj instanceof $Error && objToString === ErrorToString)) {
+ return %_CallFunction(obj, ErrorToString);
+ }
return %_CallFunction(obj, ObjectToString);
}
@@ -257,7 +261,9 @@ function IsNativeErrorObject(obj) {
// the error to string method. This is to avoid leaking error
// objects between script tags in a browser setting.
function ToStringCheckErrorObject(obj) {
- if (IsNativeErrorObject(obj)) {
+ var objToString = GetPropertyWithoutInvokingMonkeyGetters(obj, "toString");
+ if (IsNativeErrorObject(obj) ||
+ (obj instanceof $Error && objToString === ErrorToString)) {
return %_CallFunction(obj, ErrorToString);
} else {
return ToString(obj);
« no previous file with comments | « no previous file | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698