in java/src/main/java/org/apache/brooklyn/rest/client/BrooklynApiUtil.java [75:92]
public static void waitForRunningAndThrowOtherwise(BrooklynApi api, String applicationId, String taskId, Duration timeout) throws IllegalStateException {
Status finalStatus = waitForAppStatus(api, applicationId, Status.RUNNING, timeout, DEFAULT_POLL_PERIOD);
if (!Status.RUNNING.equals(finalStatus)) {
LOG.error("Application is not running. Is: " + finalStatus.name().toLowerCase());
StringBuilder message = new StringBuilder();
message.append("Application ").append(applicationId)
.append(" should be running but is ").append(finalStatus.name().toLowerCase())
.append(". ");
if (Status.ERROR.equals(finalStatus) || Status.UNKNOWN.equals(finalStatus)) {
String result = getTaskResult(api, taskId);
message.append("\nThe result of the task on the server was:\n")
.append(result);
}
throw new IllegalStateException(message.toString());
}
}