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

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: 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..de6921bafa57c5979c94cb9554ba77c0112c7b1c 100644
--- a/src/messages.js
+++ b/src/messages.js
@@ -228,7 +228,10 @@ function NoSideEffectToString(obj) {
}
}
}
- if (IsNativeErrorObject(obj)) return %_CallFunction(obj, ErrorToString);
+ if (IsNativeErrorObject(obj) ||
+ (obj instanceof $Error && obj.toString === $Error.prototype.toString)) {
Michael Starzinger 2013/08/02 11:47:04 As discussed offline: I am a little bit worried th
Mike West 2013/08/02 12:04:50 Both these suggestions make sense, and are in the
+ return %_CallFunction(obj, ErrorToString);
+ }
return %_CallFunction(obj, ObjectToString);
}
@@ -257,7 +260,8 @@ 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)) {
+ if (IsNativeErrorObject(obj) ||
+ (obj instanceof $Error && obj.toString === $Error.prototype.toString)) {
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