Is there any reason to do actors throwing an exception in Java?

I recently came across an odd pattern in two completely independent bits of Java code: when creating metadata, which is already a Throwablemore specific exception class. For example, from some Tomcat code:

Exception exception = ex.getException();
if (exception instanceof IOException) {
    throw (IOException) exception;
}

Reducing to IOExceptionme seems completely pointless, but, having seen this twice in the wild, I wonder if I am missing something?

+4
source share
1 answer

The listing tells the compiler what kind of exception this is and therefore is "checked" or "not checked."

+4
source

Source: https://habr.com/ru/post/1540278/


All Articles