Is there a way to add try-catch to every function in Javascript?

后端 未结 5 1229
心在旅途
心在旅途 2021-02-04 02:32

For error reporting, I would like to insert a try-catch wrapper around the code of every function I have.

So basically I want to replace

function foo(ar         


        
5条回答
  •  礼貌的吻别
    2021-02-04 03:18

    I needed to go fortify some code, so I wrote a function called fortify and put it in an NPM module. It's a work in progress, but it should help.

    https://github.com/infinitered/over-armour

    Bonus: it works with async functions. Feedback welcome

提交回复
热议问题