Skip to content

Instantly share code, notes, and snippets.

@think2011
Last active August 31, 2015 03:27
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 think2011/ea8fa678948a71814d88 to your computer and use it in GitHub Desktop.
Save think2011/ea8fa678948a71814d88 to your computer and use it in GitHub Desktop.
从全局捕获错误
/**
* 从全局捕获错误
* @param errMsg
* @param scriptURI
* @param lineNumber
* @param columnNumber
* @param errorObj
* @return
*/
window.onerror = function (errMsg, scriptURI, lineNumber, columnNumber, errorObj) {
setTimeout(function () {
var rst = {
"错误信息:": errMsg,
"出错文件:": scriptURI,
"出错行号:": lineNumber,
"出错列号:": columnNumber,
"错误详情:": errorObj
};
alert(JSON.stringify(rst, null, 10));
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment