pull/21653/head
Phillip Webb 5 years ago
parent 8f8bee7ccd
commit 502e2a4c64

@ -17,6 +17,7 @@
package org.springframework.boot.buildpack.platform.docker.transport;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
/**
* Exception thrown when connection to the Docker daemon fails.
@ -33,11 +34,11 @@ public class DockerConnectionException extends RuntimeException {
}
private static String buildMessage(String host, Exception cause) {
Assert.notNull(host, "host must not be null");
Assert.notNull(cause, "cause must not be null");
Assert.notNull(host, "Host must not be null");
Assert.notNull(cause, "Cause must not be null");
StringBuilder message = new StringBuilder("Connection to the Docker daemon at '" + host + "' failed");
String causeMessage = getCauseMessage(cause);
if (causeMessage != null && !causeMessage.isEmpty()) {
if (StringUtils.hasText(causeMessage)) {
message.append(" with error \"").append(causeMessage).append("\"");
}
message.append("; ensure the Docker daemon is running and accessible");
@ -48,7 +49,6 @@ public class DockerConnectionException extends RuntimeException {
if (cause.getCause() != null && cause.getCause().getClass().getName().equals(JNA_EXCEPTION_CLASS_NAME)) {
return cause.getCause().getMessage();
}
return cause.getMessage();
}

@ -35,13 +35,13 @@ class DockerConnectionExceptionTests {
@Test
void createWhenHostIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> new DockerConnectionException(null, null))
.withMessage("host must not be null");
.withMessage("Host must not be null");
}
@Test
void createWhenCauseIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> new DockerConnectionException(HOST, null))
.withMessage("cause must not be null");
.withMessage("Cause must not be null");
}
@Test

@ -100,7 +100,7 @@ The builder can be specified on the command line as well, as shown in this examp
[indent=0]
----
$ gradle bootBuildImage --builder=mine/java-cnb-builder
$ gradle bootBuildImage --builder=mine/java-cnb-builder
----
@ -164,5 +164,5 @@ The image name can be specified on the command line as well, as shown in this ex
[indent=0]
----
$ gradle bootBuildImage --imageName=example.com/library/my-app:v1
$ gradle bootBuildImage --imageName=example.com/library/my-app:v1
----

Loading…
Cancel
Save