code: 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;
    }
docs: Creates a composite IOException out of multiple IOExceptions. If there is only a single {@code
  innerException}, it will be returned as-is without wrapping into an outer exception.