dynamically load code and get line number of parse error
<p>I have a tool, similar in ways to JSFiddle, that allows me to dynamically type in javascript and run it on a page.  The code can be multiple lines, and typically will be.</p>

<p>Unfortunately if there is an exception in the code I type in, I can't get the line number of the exception if I use eval() to run the code.</p>

<p>I found a partial solution, which is instead of using</p>

<pre><code>try{
 eval(code);
 }
catch(e) {
 processException(e);
 }
</code></pre>

<p>to instead do something like this:</p>

<pre><code>var s = document.createElement('script');
s.appendChild(document.createTextNode(
    "try{\n" + 
     code +
     "}catch(e){processException(e)}"));
document.body.appendChild(s);
</code></pre>

<p>Now, if the code throws an exception, and I look at the stack trace(in my processException() function) I can get a line number of the exception (in firefox and chrome, anyway).</p>

<p>That's all well and good if it is actually a runtime exception, such as a variable not being defined.  The problem is if there is a parse error / syntax error, such as mismatched parens or the like.  I get nothing.</p>

<p>Is there any crazy workaround for this, that works on firefox and chrome, at a minimum?  Eval within eval within script tag within Function object?  I'm trying everything and haven't found anything that works.</p>
