public static String buildErrorMessage(final Throwable throwable) {
    if (throwable == null) {
      return "";
    }

    final List<String> messages = dedup(getErrorMessages(throwable));

    final String msg = messages.remove(0);

    final String causeMsg = messages.stream()
        .filter(s -> !s.isEmpty())
        .map(cause -> WordUtils.wrap(PREFIX + cause, 80, "\n\t", true))
        .collect(Collectors.joining(System.lineSeparator()));

    return causeMsg.isEmpty() ? msg : msg + System.lineSeparator() + causeMsg;
  }
@Test
  public void shouldUseCustomMsgForConnectException() {
    assertThat(
        buildErrorMessage(new ConnectException("asdf")),
        is("Could not connect to the server. Please check the server details are correct and that the server is running.")
    );
  }