private static String message(Rest.Protocol protocol, Rest.Method method,
                                  String username, String host, int port,
                                  String path, Option[] options) {

        final StringBuilder str = new StringBuilder("Exception while invoking ");
        str.append(method).append(' ');
        if (username != null) str.append(username).append('@');
        str.append(protocol.name().toLowerCase()).append("://");
        str.append(host);
        if (port > 0) str.append(':').append(port);
        if (!path.isEmpty() && !path.equals("/")) {
            if (!path.startsWith("/")) str.append('/');
            str.append(path);
        }

        final Param[] params = Stream.of(options)
            .filter(Objects::nonNull)
            .filter(o -> o.getType() == PARAM)
            .filter(Param.class::isInstance)
            .map(Param.class::cast)
            .toArray(Param[]::new);

        if (params.length > 0) {
            str.append(
                Arrays.stream(params)
                    .map(Param::toString)
                    .collect(joining("&", "?", ""))
            );
        }

        return str.toString();
    }
Exception thrown by a {@link Rest} object containing additional information
about the service that was requested.

@author Emil Forslund
@since  3.1.17
common-parent/rest/src/main/java/com/speedment/common/rest/RestException.java