Created
June 29, 2013 08:51
-
-
Save evangalen/5890424 to your computer and use it in GitHub Desktop.
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
window.onerror = function(errorMsg, url, lineNumber) { | |
var text = document.documentElement.innerHTML; | |
var lines = text.match(/^.*((\r\n|\n|\r)|$)/gm); | |
var windowOnLoadLineNumber = null; | |
for (var i = 0; i < lines.length; i++) { | |
var line = lines[i]; | |
if (line.indexOf('window.onload') === 0) { | |
windowOnLoadLineNumber = i + 3; | |
break; | |
} | |
} | |
var actualLineNumber = lineNumber; | |
if (windowOnLoadLineNumber) { | |
actualLineNumber -= windowOnLoadLineNumber; | |
} | |
console.error('' + actualLineNumber + ': ' + errorMsg); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment