public static <T> T wrapException ( final Callable<T> callable, final Function<Exception, RuntimeException> func ) {
    """
	Call and wrap {@link Exception}s into an exception provided by the
	function.
	<p>
	If the function returns {@code null}, a {@link RuntimeException} will be
	created instead.
	</p>
	
	@param callable
	the {@link Callable} to call
	@param <T>
	argument type
	@return the return value of the callable
    """
        try
        {
            return callable.call ();
        }
        catch ( final RuntimeException e )
        {
            throw e;
        }
        catch ( final Exception e )
        {
            RuntimeException t = func.apply ( e );
            if ( t == null )
            {
                t = new RuntimeException ( e );
            }
            else
            {
                // fixing the stack trace to be a bit more precise
                t.setStackTrace ( Thread.currentThread ().getStackTrace () );
            }

            throw t;
        }
    }
public static <T> T wrapException ( final Callable<T> callable, final Function<Exception, RuntimeException> func )
    {
        try
        {
            return callable.call ();
        }
        catch ( final RuntimeException e )
        {
            throw e;
        }
        catch ( final Exception e )
        {
            RuntimeException t = func.apply ( e );
            if ( t == null )
            {
                t = new RuntimeException ( e );
            }
            else
            {
                // fixing the stack trace to be a bit more precise
                t.setStackTrace ( Thread.currentThread ().getStackTrace () );
            }

            throw t;
        }
    }
public static < T > T wrapException ( final Callable < T > callable , final Function < Exception , RuntimeException > func ) { try { return callable . call ( ) ; } catch ( final RuntimeException e ) { throw e ; } catch ( final Exception e ) { RuntimeException t = func . apply ( e ) ; if ( t == null ) { t = new RuntimeException ( e ) ; } else { // fixing the stack trace to be a bit more precise t . setStackTrace ( Thread . currentThread ( ) . getStackTrace ( ) ) ; } throw t ; } }
Call and wrap {@link Exception}s into an exception provided by the
function.
<p>
If the function returns {@code null}, a {@link RuntimeException} will be
created instead.
</p>

@param callable
the {@link Callable} to call
@param <T>
argument type
@return the return value of the callable
Call and wrap { @link Exception } s into an exception provided by the function . <p > If the function returns { @code null } a { @link RuntimeException } will be created instead . < / p >