Class FilterExceptions

  • All Implemented Interfaces:

    
    public class FilterExceptions
    
                        

    A collection of helper methods for limiting which checked exceptions can escape a block of code.

    The specified exceptions, if any, will propagate normally, as will Errors and s. Any other exceptions will be wrapped in AssertionError and their unexpected-ness will be logged.

    Intended for use with native methods, where exception specs aren't enforced.

    PublicKey key = FilterExceptions.filterExceptions(
      InvalidKeyException.class,
      () -> Native.doSomethingThatMightFail(keyBytes));