diff --git a/clouddriver-ecs/src/main/java/com/netflix/spinnaker/clouddriver/ecs/provider/view/EcsServerClusterProvider.java b/clouddriver-ecs/src/main/java/com/netflix/spinnaker/clouddriver/ecs/provider/view/EcsServerClusterProvider.java index 5dbd6cafb78..4d0efb4a232 100644 --- a/clouddriver-ecs/src/main/java/com/netflix/spinnaker/clouddriver/ecs/provider/view/EcsServerClusterProvider.java +++ b/clouddriver-ecs/src/main/java/com/netflix/spinnaker/clouddriver/ecs/provider/view/EcsServerClusterProvider.java @@ -53,6 +53,7 @@ import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.NoSuchElementException; import java.util.Set; import java.util.stream.Collectors; @@ -330,12 +331,15 @@ private List getEcsCredentials() { } private AmazonCredentials getEcsCredentials(String account) { - return getEcsCredentials().stream() - .filter(credentials -> credentials.getName().equals(account)) - .findFirst().get(); + try { + return getEcsCredentials().stream() + .filter(credentials -> credentials.getName().equals(account)) + .findFirst().get(); + } catch (NoSuchElementException exception) { + throw new NoSuchElementException(String.format("There is no ECS account by the name of '%s'", account)); + } } - @Override public Map> getClusterSummaries(String application) { return getClusters();