Exception handling mechanism is well known, but the fact that Exceptions are one of the two separate sub-groups of the Throwable class is not often mastered.
The result is that often we catch exceptions but ignore errors.
Is just a little thing we have to keep in mind, mainly if your programs execute inside complex environmets.
Infact an unmanaged error could cause the whole JVM to close while you think that you have managed all the possible exceptions.
Yes: you managed all possible exceptions, but not a single error ! ;)
But there is a good news for all of you folks : Errors are exactly as Exceptions, so you can manage them the same way !
So why do we have two different groups ?
Becouse Exceptions are things you should not make to happen but must manage inside of you, while Errors are lightings hitting you when you can't do much to protect yourself.... as OutOfMemoryError !
But no metter the difference between the two group, let's manage even Errors, it's not so difficult after all:
catch (Error er)
Have a lot of fun with your JavaCode!