Try Catch from another method:
method1(){
try {
method2();
}catch(Exception e){
}
}
method2(){
try{
//ERROR FROM HERE
}catch(Exception e){
}
}
How will method1() catch the error from method2()?
method1() will not catch the error, unless you re-throw it from the catch block in method2().
void method2() {
try {
// Error here
} catch(Exception e) {
throw e;
}
}
public void method1(){
try {
test2();
} catch (IOException ex) {
//catch test2() error
}
}
public void method2() throws IOException{
}
Use throws
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With