Skip to content

Instantly share code, notes, and snippets.

@pamelafox
Created August 16, 2014 17:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pamelafox/c49504d8a0337cbf2f72 to your computer and use it in GitHub Desktop.
Save pamelafox/c49504d8a0337cbf2f72 to your computer and use it in GitHub Desktop.
Getting line number of first anonymous eval in stack in chrome
Error.prepareStackTrace = function(error, structuredStackTrace) {
return structuredStackTrace;
};
var getNumberFromChromeTrace = function(stack) {
// find first eval
var evalSite = null;
for (var i = 0; i < stack.length; i++) {
if (stack[i].isEval()) {
evalSite = stack[i];
break;
}
}
if (evalSite) {
return evalSite.getLineNumber();
}
};
var error = new Error();
console.log(getNumberFromChromeTrace(error.stack));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment