title: Tracing the source line of an error in a Javascript eval
body: <p>I'm building something that includes javascripts on the fly asynchronously, which works, but I'm looking to improve upon the error detection (so all the errors don't just appear to come from some line near the AJAX call that pulls them down.</p>
  
  <p>If I'm using eval to evaluate a multiline javascript file, is there any way to trace which line an error occurs on?</p>
  
  <p>By keeping references to the variables I need when including, I have no problem determining which file the errors occurs in. My problem is determining which <em>line</em> the error occurs in.</p>
  
  <p>Example:</p>
  
  <pre><code>try {
    eval("var valid_statement = 7; \n invalid_statement())))");
  } catch(e) {
    var err = new Error();
    err.message = 'Error in Evald Script: ' + e.message;
    err.lineNumber = ???
    throw err;
  }
  </code></pre>
  
  <p>How can I tell that the error occurred in the second line there?
  Specifically I'm interested in doing this in Firefox.</p>
  
  <p>I know that error objects have <code>e.stack</code> in Mozilla browsers, but the output doesn't seem to take into account newlines properly.</p>