Created
August 16, 2014 17:09
-
-
Save pamelafox/c49504d8a0337cbf2f72 to your computer and use it in GitHub Desktop.
Getting line number of first anonymous eval in stack in chrome
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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