How to implement top level exception handling?

前端 未结 5 1224
再見小時候
再見小時候 2020-12-31 17:19

I recently had to develop an additional module for an existing service developed by a colleague. He had placed a try/catch block in the main working function for catching al

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-31 17:57

    Ideally you want to handle an exception as close to where it occured as possible but that doesn't mean a global exception handler is a bad idea. Especially for a service which must remain running at all costs. I would continue what you have been doing. Disable it while debugging but leave it in place for production.

    Keep in mind it should be used as a safety net. Still try to catch all exceptions before they elevate that far.

提交回复
热议问题