0

I am adding a new code in my application , and this code saves some data in DB. Now, this code is after a try, catch block. If the exception occurs, the catch block returns the exception. So in that case, my code(after the catch block) will not be executed (to save data in DB).

I know that i can use finally block in this case to make sure that my code to save data is always executed irrespective of whether the exception occurs.

But i am thinking, is it a good practice to have code that does some heavy work in finally block.

If it isn't a good practice, what approach can i follow?

Amanpreet Khurana
  • 549
  • 1
  • 5
  • 17

0 Answers0