try {
eval(somejavascript);
} catch(e) {
console.log(e);
}
When I encounter runtime errors like:
TypeError: Cannot call method 'leftPad' of undefined
I wonder if there is any way to debug this error. Specifically, I'm looking for a solution that can provide the character position/line number where the error occurs in the evaluated expression, as well as a stack trace.
The stack trace provided by Chrome stops at the eval function.
Unfortunately, I am unable to debug my sample JavaScript code by putting it into a separate file due to the fact that the runtime error doesn't occur when including the code in an HTML document.