class GoogleCloudStorageExceptions {

  public static IOException createCompositeException(Collection<IOException> innerExceptions) {
    checkArgument(
        innerExceptions != null && !innerExceptions.isEmpty(),
        "innerExceptions (%s) must be not null and contain at least one element",
        innerExceptions);

    Iterator<IOException> innerExceptionIterator = innerExceptions.iterator();

    if (innerExceptions.size() == 1) {
      return innerExceptionIterator.next();
    }

    IOException combined = new IOException("Multiple IOExceptions.");
    while (innerExceptionIterator.hasNext()) {
      combined.addSuppressed(innerExceptionIterator.next());
    }
    return combined;
  }

}

class GoogleCloudStorageExceptionsTest {

  @Test
  public void testConstructorThrowsWhenInnerExceptionsAreEmpty() {

    List<IOException> emptyList = ImmutableList.of();
    assertThrows(IllegalArgumentException.class, () -> createCompositeException(emptyList));
  }

}