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); |