The error handling mechanism of new JS in the knowledge of temperature

Source: Internet
Author: User

//return in a function block's try will directly become the return value of the functionfunctionTest () {Try{ALRT (123)        return' Success '    } Catch(err) {return' Fail '    }}varresult =test () console.log (result);//fail/** * Browser global error processing * Web browser, all uncaught errors are bubbling up and eventually handled by Window.onerror, the highest-level event function. * Please note that errors in the console of the Web browser cannot be captured*/Window.onerror=function(msg, URL, line, col) {console.log (msg, URL, line, col); return true;//tell the browser that the error has been handled, no need to show to the user}/** * node. JS Global Error Handling * The Process object triggers the Uncaughtexception event. */Process.on (' Uncaughtexception ',function(Err) {Console.log (err);})/** * Domain run code and error capture*/varDomain = require (' domain '). Create ();d Omain.on (' Error ',function(Err) {Console.log (err);});/** * The basic idea of the example is that the code that might throw the error can be run here * If the code of the function call throws an error, it will trigger the domain's error event. Proper handling can be done by listening for error events*/Domain.run (function () {    /*some code that might throw an error*/})

The error handling mechanism of new JS in the knowledge of temperature

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.