I have this line come up in the console, only in Firefox, from my JavaScript application I'm developing:
It seems relatively harmless, but I'm curious if there's any way to deduce its origin, because it must come from somewhere, even if it claims 'unknown'. Wrapping the entire script in a try/catch block and toggling Firefox's "Pause on Exception" setting doesn't do anything, which seems to imply it's a special exception? I have some ideas what parts of my code might be causing it that are using Working Draft APIs, but I'm more interested in why it reports this way and what I can do about it. Does Firefox not provide any more detail?
There's a few ways you could try to squash this bug.
One thing that's very tedious but will get you the line number of the exception is code that looks like:
and so on, and if you get this in the console:
then you know that baz() was causing the error. Another way is to use the debugger, like so:
and you can use firefox's debugger to go over each line and see which one throws the error to the console.
If you have a lot of code, you could try the divide-and-conquer trick, like this:
Then, if the console looks like this:
Then the problem is in block 2. Then, you could do this:
And if you see:
Then you know that
var barArr = barStr.split("");
is your problem. From then, you might want to log variable values, like this:And if you see this in the console:
Then you know that
bar()
is returningundefined
(instead of a string), which does not have asplit
method. Then you look at the code of bar to determine if, say you forgot a parameter? Mabeybar
looks like this:and
strings
is an object with something in it. Therefore,strings[undefined]
will returnundefined
, which does not have asplit
method. Bug squashed!