Java Suppressed Exceptions

An Java exception can be thrown from the block of code associated with the try-with-resources statement.

If an exception is thrown from the try block and one or more exceptions are thrown from the try-with-resources statement, then those exceptions thrown from the try-with-resources statement are suppressed, and the exception thrown by the block is the one that is thrown by the mothod.

Retrieve Java suppressed exceptions by calling the Throwable.getSuppressed method from the exception thrown by the try block.

Comments