public static <T> CloseableResource<T> of(T resource, Closer<T> closer) {
    checkArgument(resource != null, "Resource must be non-null");
    checkArgument(closer != null, "%s must be non-null", Closer.class.getName());
    return new CloseableResource<>(resource, closer);
  }
@Test
  public void wrapsExceptionsInCloseException() throws Exception {
    Exception wrapped = new Exception();
    thrown.expect(CloseException.class);
    thrown.expectCause(is(wrapped));
    try (CloseableResource<Foo> ignored =
        CloseableResource.of(
            new Foo(),
            foo -> {
              throw wrapped;
            })) {
      // Do nothing.
    }
  }