Catching Syntax Errors

In the following example, we have files which throw various JS errors. We've created a window.onerror handler to catch them and display them in the sandbox. Line numbers are preserved, even when code is evaluated. Additionally, "sourceMap" can be turned on as a debug option, and files will be forced through the window.eval() in order to take advantage of advanced debugging in Firebug (using the @sourceURL parameter).