-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
  • 301
  • 4
  • 7

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
  • 12,413
  • 14
  • 35