3

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
  • I'm surprised that this is possible. Even if it was generated code that's being evaluated, eval() errors still are more informative than your example. Commented Sep 10, 2010 at 14:30

4 Answers 4

4

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.

Sign up to request clarification or add additional context in comments.

1 Comment

I recommend using Firebug's console.log() instead of alert(), because closing the alert windows is annoying.
2

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 ...

Comments

1

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.

1 Comment

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.") } ...
1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.