Home / Class/ DockerEngineException Class — spring-boot Architecture

DockerEngineException Class — spring-boot Architecture

Architecture documentation for the DockerEngineException class in DockerEngineException.java from the spring-boot codebase.

Entity Profile

Relationship Graph

Source Code

buildpack/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/transport/DockerEngineException.java lines 37–112

public class DockerEngineException extends RuntimeException {

	private final int statusCode;

	private final @Nullable String reasonPhrase;

	private final @Nullable Errors errors;

	private final @Nullable Message responseMessage;

	public DockerEngineException(String host, URI uri, int statusCode, @Nullable String reasonPhrase,
			@Nullable Errors errors, @Nullable Message responseMessage, byte @Nullable [] content) {
		super(buildMessage(host, uri, statusCode, reasonPhrase, errors, responseMessage, content));
		this.statusCode = statusCode;
		this.reasonPhrase = reasonPhrase;
		this.errors = errors;
		this.responseMessage = responseMessage;
	}

	/**
	 * Return the status code returned by the Docker API.
	 * @return the statusCode the status code
	 */
	public int getStatusCode() {
		return this.statusCode;
	}

	/**
	 * Return the reason phrase returned by the Docker API.
	 * @return the reasonPhrase
	 */
	public @Nullable String getReasonPhrase() {
		return this.reasonPhrase;
	}

	/**
	 * Return the errors from the body of the Docker API response, or {@code null} if the
	 * errors JSON could not be read.
	 * @return the errors or {@code null}
	 */
	public @Nullable Errors getErrors() {
		return this.errors;
	}

	/**
	 * Return the message from the body of the Docker API response, or {@code null} if the
	 * message JSON could not be read.
	 * @return the message or {@code null}
	 */
	public @Nullable Message getResponseMessage() {
		return this.responseMessage;
	}

	private static String buildMessage(String host, URI uri, int statusCode, @Nullable String reasonPhrase,
			@Nullable Errors errors, @Nullable Message responseMessage, byte @Nullable [] content) {
		Assert.notNull(host, "'host' must not be null");
		Assert.notNull(uri, "'uri' must not be null");
		StringBuilder message = new StringBuilder(
				"Docker API call to '" + host + uri + "' failed with status code " + statusCode);
		if (StringUtils.hasLength(reasonPhrase)) {
			message.append(" \"").append(reasonPhrase).append("\"");
		}
		if (responseMessage != null && StringUtils.hasLength(responseMessage.getMessage())) {
			message.append(" and message \"").append(responseMessage.getMessage()).append("\"");
		}
		else if (statusCode == HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED && !ObjectUtils.isEmpty(content)) {
			String contentString = new String(content, StandardCharsets.UTF_8);
			message.append(" and content \"").append(contentString.trim()).append("\"");
		}
		if (errors != null && !errors.isEmpty()) {
			message.append(" ").append(errors);
		}
		return message.toString();
	}

}

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free