de.gesellix.docker.client.container.DockerResponseHandler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of docker-client Show documentation
Show all versions of docker-client Show documentation
A Docker client for the JVM written in Groovy
package de.gesellix.docker.client.container;
import de.gesellix.docker.engine.EngineResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
public class DockerResponseHandler {
public void ensureSuccessfulResponse(EngineResponse response, Throwable throwable) throws Throwable {
if (response == null || !response.getStatus().getSuccess() || hasError(response)) {
logError(response);
throw throwable;
}
}
public void logError(final EngineResponse response) {
if (response != null && response.getContent() instanceof String) {
log.error("request failed: '{}'", response.getContent());
} else {
log.error("request failed: {}", getErrors(response));
}
}
public boolean hasError(EngineResponse response) {
return getErrors(response).size() > 0;
}
public List