Some tweaks to error messages for services and buildpack when failing to
fetch them.
This commit is contained in:
@@ -29,7 +29,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
*/
|
||||
public class CfCliParamsProvider implements ClientParamsProvider {
|
||||
|
||||
public static final String NO_CLI_TARGETS_FOUND_MESSAGE = "No Cloudfoundry Targets: Please use the cf CLI to login.";
|
||||
public static final String NO_CLI_TARGETS_FOUND_MESSAGE = "No Cloud Foundry targets found: Use CF CLI to login";
|
||||
public static final String TARGET = "Target";
|
||||
public static final String REFRESH_TOKEN = "RefreshToken";
|
||||
public static final String ORGANIZATION_FIELDS = "OrganizationFields";
|
||||
|
||||
@@ -37,6 +37,12 @@ public abstract class AbstractCFHintsProvider implements Callable<Collection<YVa
|
||||
this.targetCache = targetCache;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used in error messages. For example "Failed to get ${type-name}s from Cloudfoundry".
|
||||
* @return
|
||||
*/
|
||||
protected abstract String getTypeName();
|
||||
|
||||
@Override
|
||||
public Collection<YValueHint> call() throws Exception {
|
||||
|
||||
@@ -63,15 +69,8 @@ public abstract class AbstractCFHintsProvider implements Callable<Collection<YVa
|
||||
} else {
|
||||
// Log any other error
|
||||
logger.log(Level.SEVERE, ExceptionUtil.getMessage(e), e);
|
||||
|
||||
if (ExceptionUtil.getThrowable(e, IOException.class) != null) {
|
||||
throw new ValueParseException(
|
||||
"Connection failure to Cloud Foundry. Please check the log for more details.");
|
||||
|
||||
} else {
|
||||
throw new ValueParseException(
|
||||
"Failed to fetch values from Cloud Foundry. Please check the log for more details.");
|
||||
}
|
||||
throw new ValueParseException(
|
||||
"Failed to get "+getTypeName()+" from Cloud Foundry: "+ExceptionUtil.getMessage(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,11 +51,16 @@ public class ManifestYamlCFBuildpacksProvider extends AbstractCFHintsProvider {
|
||||
// resolved. Otherwise
|
||||
// return non-empty list of buildpacks. For CF targets, a non-empty list
|
||||
// of buildpacks is
|
||||
// typically expected.
|
||||
// typically expected.
|
||||
return !hints.isEmpty() ? hints : null;
|
||||
}
|
||||
|
||||
protected String getBuildpackLabel(CFTarget target, CFBuildpack buildpack) {
|
||||
return buildpack.getName() + " (" + target.getName() + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTypeName() {
|
||||
return "Buildpack";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,4 +59,9 @@ public class ManifestYamlCFServicesProvider extends AbstractCFHintsProvider {
|
||||
return service.getName() + " - " + service.getPlan() + " (" + cfClientTarget.getParams().getOrgName() + " - "
|
||||
+ cfClientTarget.getParams().getSpaceName() + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTypeName() {
|
||||
return "Service";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user