Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uninformative error message in Object.toJSON() #215

Open
jwestbrook opened this issue May 16, 2014 · 0 comments
Open

Uninformative error message in Object.toJSON() #215

jwestbrook opened this issue May 16, 2014 · 0 comments

Comments

@jwestbrook
Copy link
Collaborator

previous lighthouse ticket #1283
by Victor


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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants