A small tool to automatically wrap your code with custom global exception handler by using the technology of AST.
npm install
cd test
node test
for input code:
var test = function(){
console.log('test');
}
then transform it by try-catch-global.js:
var outputCode = globalFuncTryCatch(inputCode, function (error) {
console.log(error);
});
the output code will be:
var test = function() {
try {
console.log("test");
} catch (error) {
(function(error) {
console.log(error);
})(error);
}
};