JS Code Error Monitoring code

Source: Internet
Author: User

Window.onerror = function (msg,url,line,col,error) {//No URL is not escalated!    The escalation also does not know the error if (msg! = "Script error." &&!url) {return true; }//Asynchronous Way//I have encountered an Ajax blocking escalation in window.onunload//due to a client forcing shutdown WebView caused this blockage to escalate with network Error//I guess the window.onerror here The flow is bound to execute before it is closed//and the escalation after leaving the article is a loss for the business//So I'm going to banish the execution here to the asynchronous event to execute//The exception number of the script is reduced by 10 times times setTimeout (function () {var da        Ta = {}; Not all browsers support col parameter col = col | | (window.event && window.event.errorCharacter) | |        0;  data.url = URL;        Data.line = line;        Data.col = col; if (!! Error &&!!        Error.stack) {//If the browser has stack information//directly using DATA.MSG = Error.stack.toString (); }else if (!!            Arguments.callee) {//try to get stack information via callee var ext = [];            var f = arguments.callee.caller, c = 3;               Here only three stack information is taken while (F && (--c>0)) {Ext.push (f.tostring ()); if (f = = = F.caller){break;//If there is a ring} f = F.caller;            ext = Ext.join (",");        data.msg = ext;    }//Upload data to the background! },0);  return true;};

JS code error Monitoring code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.