-4

Please see below for the description of the problem.

try {
 //some comde may throw error/exception etc 

} catch (Exception e) {
  //do something
} catch (Error e) {   //is it possible this line may get into action? I mean is there any case Exception may not be enough? so Error needs to take over the control?
 //do something
}
James
  • 441
  • 2
  • 6
  • 9

1 Answers1

1

Yes of course - for example AssertionError is extending Error. To catch all exceptions you should catch Throwable

try {
    // ...
} catch(Throwable t) {
    // ...
}

take a look also at: Differences between Exception and Error

m.antkowicz
  • 13,268
  • 18
  • 37