public static RuntimeException propagate ( final Exception exception ) { if ( RuntimeException . class . isAssignableFrom ( exception . getClass ( ) ) ) { return ( RuntimeException ) exception ; } return new RuntimeException ( "Repropagated " + exception . getMessage ( ) , exception ) ; //NOPMD }
Propagate a Throwable as a RuntimeException . The Runtime exception bases it s message not the message of the Throwable and the Throwable is set as it s cause . This can be used to deal with exceptions in lambdas etc .