@ SuppressWarnings ( "unchecked" ) public static < T , E extends Throwable > void exceptionListener ( CompletableFuture < T > completableFuture , Class < E > exceptionClass , Consumer < E > exceptionListener ) { completableFuture . whenComplete ( ( r , ex ) -> { if ( ex != null && exceptionClass . isAssignableFrom ( ex . getClass ( ) ) ) { Callbacks . invokeSafely ( exceptionListener , ( E ) ex , null ) ; } } ) ; }
Registers an exception listener to the given CompletableFuture for a particular type of exception .