io.linguarobot.aws.cdk.maven.StackDeploymentException Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aws-cdk-maven-plugin Show documentation
Show all versions of aws-cdk-maven-plugin Show documentation
The AWS CDK Maven plugin produces and deploys CloudFormation templates based on the cloud infrastructure defined
by means of CDK. The goal of the project is to improve the experience of Java developers while working with
CDK by eliminating the need for installing Node.js and interacting with the CDK application by means of CDK
Toolkit.
package io.linguarobot.aws.cdk.maven;
import javax.annotation.Nullable;
/**
* An exception that is thrown in case CloudFormation stack can't be deployed for some reason.
*/
public class StackDeploymentException extends CdkPluginException {
private final String stackName;
private final ResolvedEnvironment environment;
protected StackDeploymentException(String stackName,
ResolvedEnvironment environment,
String message,
@Nullable Throwable cause) {
super(formatErrorMessage(stackName, environment, message), cause);
this.stackName = stackName;
this.environment = environment;
}
private static String formatErrorMessage(String stackName, ResolvedEnvironment environment, @Nullable String message) {
StringBuilder errorMessage = new StringBuilder();
errorMessage.append("The stack '")
.append(stackName)
.append("' cannot be deployed in ")
.append(environment.getName())
.append(" environment");
if (message != null) {
errorMessage.append(". ").append(message);
}
return errorMessage.toString();
}
public String getStackName() {
return stackName;
}
public ResolvedEnvironment getEnvironment() {
return environment;
}
public static Builder builder(String stackName, ResolvedEnvironment environment) {
return new Builder(stackName, environment);
}
public static class Builder {
private final String stackName;
private final ResolvedEnvironment environment;
private String message;
private Throwable cause;
private Builder(String stackName, ResolvedEnvironment environment) {
this.stackName = stackName;
this.environment = environment;
}
public Builder withCause(String cause) {
this.message = cause;
return this;
}
public Builder withCause(Throwable cause) {
this.cause = cause;
return this;
}
public StackDeploymentException build() {
return new StackDeploymentException(stackName, environment, message, cause);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy