try/catch有局限-uncaughtException事件倒挂process对象上捕获异步回调里的异常
process.on('uncaughtException', function (error) {//})process.nextTick(function () {fs.readFile('/index.js', function (error, str) {if (error) throw error;})})
domain模块(nodejs内置模块)
写法1:run是对enter/exit的简单封装
const domain = require('domain');let d = d.create();d.on('error', function(error) {})d.run(function() {// TODO})
写法2:enter+exit (有限制: 不便处理多个domain混合、嵌套)
d.enter();// TODOd.exit();
d.bind()
d.intercept()
