i would like to know your opinions of what is the correct way of applying the try-catch block to capture exceptions.
Let say i have 4 levels of hierarchy methods that are calls like this:
method1(){
method2(){
method3(){
method4()
}
morecode that depend of what happend in method3
}
morecode that depend of what happend in method2
}
So what i do is wrap from inside out the possible methods that are going to present exceptions and as i have code that depends in the different levels of what happen in those methods i propagate the exception using "throw" sentences to avoid that those codes produce a crash.
method1(){
try
method2(){
try
method3(){
try
method4()
catch
throw
}
catch
throw
morecode that depend of what happend in method3
}
catch
return
morecode that depend of what happend in method2
}
Is this the correct way? or i'm making a terrible use of "throw" sentence?