diff --git a/PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/intellij/runner/springcloud/deploy/SpringCloudDeploymentState.java b/PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/intellij/runner/springcloud/deploy/SpringCloudDeploymentState.java index caa9c0fd700..185cf205860 100644 --- a/PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/intellij/runner/springcloud/deploy/SpringCloudDeploymentState.java +++ b/PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/intellij/runner/springcloud/deploy/SpringCloudDeploymentState.java @@ -176,12 +176,16 @@ protected void onSuccess(AppResourceInner result, @NotNull RunProcessHandler pro @Override protected void onFail(Throwable throwable, @NotNull RunProcessHandler processHandler) { - DefaultLoader.getUIHelper().showException(throwable.getMessage(), throwable, "Deployed failed", false, true); try { processHandler.println(throwable.getMessage(), ProcessOutputTypes.STDERR); } catch (Exception ex) { // should not propagate error infinitely } + // todo: create new user error base exception + if (!(throwable instanceof SpringCloudValidationException)) { + DefaultLoader.getUIHelper().showException(throwable.getMessage(), throwable, "Deployed failed", + false, true); + } processHandler.notifyComplete(); } @@ -200,16 +204,15 @@ private void validateSpringCloudAppArtifact(String finalJar) throws AzureExecuti final Attributes manifestAttributes = jarFile.getManifest().getMainAttributes(); final String mainClass = manifestAttributes.getValue(MAIN_CLASS); if (StringUtils.isEmpty(mainClass)) { - throw new AzureExecutionException(String.format(MAIN_CLASS_NOT_FOUND, finalJar)); + throw new SpringCloudValidationException(String.format(MAIN_CLASS_NOT_FOUND, finalJar)); } final String library = manifestAttributes.getValue(SPRING_BOOT_LIB); if (StringUtils.isEmpty(library)) { - // it is fine to deploy non-spring app to azure spring cloud return; } final Map dependencies = getSpringAppDependencies(jarFile.entries(), library); if (!dependencies.containsKey(SPRING_BOOT_AUTOCONFIGURE)) { - throw new AzureExecutionException(String.format(NOT_SPRING_BOOT_Artifact, finalJar)); + throw new SpringCloudValidationException(String.format(NOT_SPRING_BOOT_Artifact, finalJar)); } final String springVersion = dependencies.get(SPRING_BOOT_AUTOCONFIGURE); final List missingDependencies = new ArrayList<>(); diff --git a/PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/intellij/runner/springcloud/deploy/SpringCloudValidationException.java b/PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/intellij/runner/springcloud/deploy/SpringCloudValidationException.java new file mode 100644 index 00000000000..da309680279 --- /dev/null +++ b/PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/intellij/runner/springcloud/deploy/SpringCloudValidationException.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) Microsoft Corporation + * + * All rights reserved. + * + * MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated + * documentation files (the "Software"), to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of + * the Software. + * + * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO + * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.microsoft.intellij.runner.springcloud.deploy; + +import com.microsoft.azure.common.exceptions.AzureExecutionException; + +public class SpringCloudValidationException extends AzureExecutionException { + public SpringCloudValidationException(final String errorMessage, final Throwable err) { + super(errorMessage, err); + } + + public SpringCloudValidationException(final String errorMessage) { + super(errorMessage); + } +}