Skip to content

Commit 7d4184e

Browse files
Merge pull request #52 from victor-homyakov/patch-12
Explain the `TypeError` thrown when a circular reference is found while serializing an object to JSON. (Victor Homyakov, Andrew Dupont)
2 parents 5cc2414 + b130f8f commit 7d4184e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/prototype/lang/object.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,9 @@
190190
case 'object':
191191

192192
for (var i = 0, length = stack.length; i < length; i++) {
193-
if (stack[i] === value) { throw new TypeError(); }
193+
if (stack[i] === value) {
194+
throw new TypeError("Cyclic reference to '" + value + "' in object");
195+
}
194196
}
195197
stack.push(value);
196198

0 commit comments

Comments
 (0)