private void checkSuccessfulResponse(final Response response, final String message) {
        if (!response.isSuccessful()) {
            String body = null;
            if (response.body() != null) {
                try {
                    body = response.body().string();
                } catch (IOException e) {
                    logger().debug("Unable to read body of response: {}", response, e);
                }
            }

            throw new IllegalStateException(message + ": " + response + ", body=" + (body == null ? "<null>" : body));
        }
    }
Helper method to check if the response is successful and release the body if needed.

@param response the response to check.
@param message the message that should be part of the exception of not successful.
modules/couchbase/src/main/java/org/testcontainers/couchbase/CouchbaseContainer.java