Beanshell catch(ex): Exception or Throwable?

What type of exception is caught by the beanshell catch(ex): Exception or Throwable?.


try {
    .... } catch (ex) {     }

Asked by: Carlos124 | Posted: 21-01-2022

Answer 1

That loosely typed catch will catch everything "Throwable." That will include Errors, Exceptions and their myriad children. You can easily confirm this with:

try {
  new Throwable("Something Exceptional");
} catch (ex) {

Answered by: Fiona835 | Posted: 22-02-2022

Answer 2

Throwable is a superclass (essentially) of Exception--anything that Exception catches will also be caught by Throwable. In general usage they are the same, you rarely (if ever) see other throwable types.

Answered by: Daryl209 | Posted: 22-02-2022

Similar questions

Still can't find your answer? Check out these amazing Java communities for help...

Java Reddit Community | Java Help Reddit Community | Java Community | Java Discord | Java Programmers (Facebook) | Java developers (Facebook)