Java exception not caught

Because some exceptions don’t derive from Exception – e.g. Throwable and Error.

Basically the type hierarchy is:

       Object
         |
      Throwable
     /         \
Exception      Error

Only Throwables and derived classes can be thrown, so if you catch Throwable, that really will catch everything.

Throwable, Exception and any exception deriving from Exception other than those derived from RuntimeException count as checked exceptions – they’re the ones that you have to declare you’ll throw, or catch if you call something that throws them.

All told, the Java exception hierarchy is a bit of a mess…

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)