private void throwException(String errorMessage,
                                Exception cause,
                                List<Message> messages)
            throws IOException {

        LOGGER.error("{}, {}, {}", errorMessage, cause, messages);
        var buf = new StringBuilder(errorMessage);
        if (cause != null) {
            buf.append("\n    ");
            buf.append(cause.getMessage());
        }
        if (!messages.isEmpty()) {
            buf.append("\n\nAdditional information:");
            for (var m : messages) {
                buf.append("\n    ");
                buf.append(m);
            }
        }
        throw new IOException(buf.toString(), cause);
    }
Creates an exception with as much context info as possible for display
to the user in the UI.

@param errorMessage The message that describes the problem. Must not
                    be null.
@param cause        The exception that caused this error. Can be null if no
                    triggering exception.
@param messages     Any messages from the export. Never null. Can be empty.
@throws IOException to indicate to the caller that an error has occurred.
stroom-gitrepo/stroom-gitrepo-impl/src/main/java/stroom/gitrepo/impl/GitRepoStorageService.java