public void logAndThrow(Function<String, RuntimeException> exceptionCreator, String errorMessage, Object... messageParams) {
    String msg = String.format(errorMessage, messageParams);
    logger.error(msg);
    throw exceptionCreator.apply(msg);
  }
Formats an error message with parameters using {@code String.format}, logs it using {@code logger},
and throws an unchecked exception with the same message created by {@code exceptionCreator}.
ambari-server/src/main/java/org/apache/ambari/server/utils/LoggingPreconditions.java