views:

25

answers:

4

Hi there,

I'm just about to freak out. I currently have to work on a website that some other guy did and I am asked to maintain etc. It uses jQuery and a bunch of drupal modules. At some point i get some syntax error, so that some js works, and some does not. My big big problem is to find the syntax error. Neither Firebug, nor WebInspector give me decent information:

Error: uncaught exception: Syntax error, unrecognized expression: //

Yeah… that's it. No lines, no filename, no more hints. Has anyone an idea how to deal with this?

Thanks for any usefull hints.

+1  A: 

you might try a tool like the closure compiler, which will give warnings and errors for blocks of code. otherwise, it's brute force with alert('checkpoint'); to determine how far into your code you get before things break.

lincolnk
I recommend using Firebug's `console.log()` instead of `alert()`, because closing the alert windows is annoying.
Reinis I.
A: 

I believe Chrome's console pinpoints the line of the error.... Right-click on the page > Inspect element, then in the bottom right corner of the window that pops up, click on the red X icon, then click on the link for the error, enable Resource tracking if necessary...

Also, put the code trough JSLint and correct the code accordingly ...

Šime Vidas
A: 

I'd start by commenting out all but one javascript include at a time in the html, if possible (unless they're a tangled mess of dependencies). Other than that, can you try using a debugger to step through it line by line? Finally, if it's not too much work, maybe it's worth writing unit tests. It'll also help you fully understand the person's code, and probably identify any deeper logic-level bugs.

Aidan Brumsickle
I just had a thought... maybe they used some obnoxiously unhelpful try-catch blocks... you know, of this sort: `try { ... } catch (exception) { console.debug("there was an error.") }` ...
Aidan Brumsickle
A: 

JSLint may be what you need, but I bet it finds a lot more problems than just your elusive syntax error.

JoshNaro