#1283 new
Victor

Uninformative error message in Object.toJSON()

Reported by Victor | November 16th, 2011 @ 03:12 PM

When object passed to Object.toJSON() has cyclic references, function Str() throws error with unclear and uninformative default message (e.g. in Opera Unhandled Error: Incorrect value to a primitive operation):

    for (var i = 0, length = stack.length; i < length; i++) {
      if (stack[i] === value) { throw new TypeError(); }
    }

something pointing to reason of exception like

    for (var i = 0, length = stack.length; i < length; i++) {
      if (stack[i] === value) {
        throw new TypeError("Cyclic reference to '" + value + "' in object");
      }
    }

would be much better. Also it is harder to debug code when entire expression if (...) {...} is written on single line - impossible without conditional breakpoint.

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

The Prototype JavaScript library.

Shared Ticket Bins

People watching this ticket

Pages