Add trycatch to your magic comment
npm install babel-plugin-catch``sh`
npm install babel-plugin-catch or yarn add babel-plugin-catch
`javascript
const test = (num/ catch /) => {
}
class Test{
test(num, num2/ catch /){
}
test = (num, num2/ catch /) => {
}
}
`
.babelrc
`javascript
{
"plugins": [
["babel-plugin-catch", {
comment?: 'catch',
catchCode?: (e) => {
},
finallyCode?: () =>{
}
}]
]
}
`
`sh`
$ babel --plugins babel-plugin-catch script.js
`javascript``
require("babel-core").transform("code", {
plugins: ["babel-plugin-catch"]
});