讀取配置文件
var file = "D:\\httpproxy\\config.json";
proxyPassConfig = fs.readFileSync(file).toString();
proxyPassConfig = JSON.parse(proxyPassConfig);
console.info("test"+proxyPassConfig["/addons"]);
使用uncaughtException
我們可以uncaughtException來全局捕獲未捕獲的Error,同時你還可以將此函數的調用棧打印出來,捕獲之後可以有效防止node進程退出,如:
process.on('uncaughtException', function (err) {
//打印出錯誤
console.log(err);
//打印出錯誤的調用棧方便調試
console.log(err.stack);
});