I'd check out window.onerror
Example:
window.onerror = function(message, url, lineNumber) {
//save error and send to server for example.
return true;
};
Keep in mind that returning true will prevent the firing of the default handler, and returning false will let the default handler run.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…