//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