class ResponseUtils {

    @NotNull
    static Observable<String> attemptToReadErrorResponse(@NotNull final HttpClientResponse<ByteBuf> resp) {
        final HttpResponseHeaders headers = resp.getHeaders();
        final String contentType = resp.getHeaders().get(HttpHeaderNames.CONTENT_TYPE);
        if (headers.isContentLengthSet() && headers.getContentLength() > 0 ) {
            if (contentType != null && contentType.startsWith("text/plain")) {
                return resp.getContent()
                    .map(r -> r.toString(StandardCharsets.UTF_8));
            } else {
                resp.ignoreContent();
                final String errMsg = getErrMsg(contentType);
                return Observable.just(errMsg);
            }
        } else {
            return Observable.just("");
        }
    }

    private  ResponseUtils();

}