I've caught an exception!! Now what?

后端 未结 16 906
逝去的感伤
逝去的感伤 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:35

    It depends on your business logic, but you may want to do one or more of the following.

    • Rollback your transaction
    • Log the error
    • Alert any user of the application
    • Retry the operation
    • Rethrow the exception

    You may also wish to check if the exception is of a type you can handle before one of the above.

    A good article on VB.NET exception handling is Exception Handling in VB.NET by Rajesh VS.

提交回复
热议问题