public static RuntimeException wrapIf(boolean condition, Throwable t) {
    if (condition) {
      return wrap(t);
    }

    if (t instanceof RuntimeException) {
      return (RuntimeException) t;
    }

    return new RuntimeException(t);
  }
@Test
  public void testWrapIfReturnsSourceRuntimeExceptionWhenFalse() {
    RuntimeException runtimeException = new RuntimeException("oh noes!");
    RuntimeException wrapped = UserCodeException.wrapIf(false, runtimeException);

    assertEquals(runtimeException, wrapped);
  }