diff --git a/vscode-extensions/commons/commons-cf/src/main/java/org/springframework/ide/vscode/commons/cloudfoundry/client/cftarget/CfCliParamsProvider.java b/vscode-extensions/commons/commons-cf/src/main/java/org/springframework/ide/vscode/commons/cloudfoundry/client/cftarget/CfCliParamsProvider.java index 2d1770505..fa6ca2e29 100644 --- a/vscode-extensions/commons/commons-cf/src/main/java/org/springframework/ide/vscode/commons/cloudfoundry/client/cftarget/CfCliParamsProvider.java +++ b/vscode-extensions/commons/commons-cf/src/main/java/org/springframework/ide/vscode/commons/cloudfoundry/client/cftarget/CfCliParamsProvider.java @@ -88,7 +88,7 @@ public class CfCliParamsProvider implements ClientParamsProvider { */ @Override public String noParamsAvailableMessage() { - return "No Cloud Foundry targets. Please use cf CLI to configure and login to a Cloud Foundry target."; + return "No valid Cloud Foundry connection found. Please use cf CLI to configure and login to Cloud Foundry."; } private File getConfigJsonFile() throws IOException, InterruptedException { diff --git a/vscode-extensions/vscode-manifest-yaml/src/main/java/org/springframework/ide/vscode/manifest/yaml/AbstractCFHintsProvider.java b/vscode-extensions/vscode-manifest-yaml/src/main/java/org/springframework/ide/vscode/manifest/yaml/AbstractCFHintsProvider.java index 551e9db43..0cc883d1b 100644 --- a/vscode-extensions/vscode-manifest-yaml/src/main/java/org/springframework/ide/vscode/manifest/yaml/AbstractCFHintsProvider.java +++ b/vscode-extensions/vscode-manifest-yaml/src/main/java/org/springframework/ide/vscode/manifest/yaml/AbstractCFHintsProvider.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.springframework.ide.vscode.manifest.yaml; +import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -40,30 +41,28 @@ public abstract class AbstractCFHintsProvider implements Provider get() { Collection hints = new ArrayList<>(); - List targets = null; + // TODO: Probably not the most ideal thing to do, but for now show any + // CF errors + // in the CA UI, as well as cases where there are no targets try { - targets = targetsFactory.getTargets(); - } catch (Throwable e) { - // Don't throw exception. Just log, and instead show a "no targets" - // hint below - logger.log(Level.SEVERE, e.getMessage(), e); - } - - if (targets == null || targets.isEmpty()) { - // TODO: Probably a wrong thing to do, but for now show that - // there are - // no targets as a "hint" so that it appears - // in CA UI - hints.add(new BasicYValueHint(EMPTY_VALUE, targetsFactory.noTargetsMessage())); - } else { - try { + List targets = targetsFactory.getTargets(); + if (targets == null || targets.isEmpty()) { + hints.add(new BasicYValueHint(EMPTY_VALUE, targetsFactory.noTargetsMessage())); + } else { Collection resolvedHints = getHints(targets); hints.addAll(resolvedHints); - } catch (Exception e) { - throw ExceptionUtil.unchecked(e); + } + } catch (Throwable e) { + logger.log(Level.SEVERE, e.getMessage(), e); + // Don't throw exception as to allow the CA to be displayed to the + // user. + if (e instanceof IOException || ExceptionUtil.getDeepestCause(e) instanceof IOException) { + hints.add(new BasicYValueHint(EMPTY_VALUE, "Connection failure. " + targetsFactory.noTargetsMessage())); + } else { + hints.add(new BasicYValueHint(EMPTY_VALUE, + "Unable to fetch Cloud Foundry proposals due to: " + e.getMessage())); } } - return hints; } diff --git a/vscode-extensions/vscode-manifest-yaml/src/main/java/org/springframework/ide/vscode/manifest/yaml/ManifestYamlCFBuildpacksProvider.java b/vscode-extensions/vscode-manifest-yaml/src/main/java/org/springframework/ide/vscode/manifest/yaml/ManifestYamlCFBuildpacksProvider.java index fed914478..88aa4bb89 100644 --- a/vscode-extensions/vscode-manifest-yaml/src/main/java/org/springframework/ide/vscode/manifest/yaml/ManifestYamlCFBuildpacksProvider.java +++ b/vscode-extensions/vscode-manifest-yaml/src/main/java/org/springframework/ide/vscode/manifest/yaml/ManifestYamlCFBuildpacksProvider.java @@ -43,6 +43,10 @@ public class ManifestYamlCFBuildpacksProvider extends AbstractCFHintsProvider { } } } + + if (hints.isEmpty()) { + hints.add(new BasicYValueHint(EMPTY_VALUE, "No buildpacks found. " + targetsFactory.noTargetsMessage())); + } return hints; }