I've caught an exception!! Now what?

后端 未结 16 945
逝去的感伤
逝去的感伤 2021-02-02 05:15

I\'ve started using try-catch blocks (a bit late, I know!), but now I\'m not sure what to do with the exception once I\'ve caught it. What should I do?



        
16条回答
  •  旧巷少年郎
    2021-02-02 05:39

    First, if there is no way for your application to handle the exception then you shouldn't catch it in the first place (logging can be done via exception event handlers without catching).

    If there is something you can do then do that. For example, roll back the transaction and report it failed to the user. This is going to depend on your application.

提交回复
热议问题