What is the best strategy for using Try / Catch blocks:
try {
//FAÇA ALGO
}
catch(Exception ex){
//LOGAR O ERRO
//LANÇAR O ERRO PARA CIMA?
}
Example:
A tax calculation operation initiates the process by the UI triggering a one-button event. This event will call an application method where it will handle the data and perform the proper operations. Let's assume that the transaction as a whole will only be satisfied if the entire process occurs well, ie database persistence, and common operations.
If an exception occurs in a method that does a calculation before the information is persisted or an exception in data persistence, what should be done?
- Put all exceptions up by logging them in to each internal method and displaying the error on the screen?
- How to undo the entire transaction if the exception happens at a point in which it executes?