/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.teradata.benchto.driver;

import com.teradata.benchto.driver.execution.BenchmarkExecutionResult;

import java.util.List;

public class FailedBenchmarkExecutionException
        extends BenchmarkExecutionException
{

    private final List<BenchmarkExecutionResult> failedBenchmarkResults;
    private final int benchmarksCount;

    public FailedBenchmarkExecutionException(List<BenchmarkExecutionResult> failedBenchmarkResults, int benchmarksCount)
    {
        super("" + failedBenchmarkResults.size() + " benchmarks failed");
        this.failedBenchmarkResults = failedBenchmarkResults;
        this.benchmarksCount = benchmarksCount;
    }

    public List<BenchmarkExecutionResult> getFailedBenchmarkResults()
    {
        return failedBenchmarkResults;
    }

    public int getBenchmarksCount()
    {
        return benchmarksCount;
    }
}

@@ -593,16 +593,60 @@
 river;%0A%0A
+import com.google.common.collect.Iterables;%0A
 import c
@@ -733,16 +733,122 @@
 .List;%0A%0A
+import static com.google.common.base.Preconditions.checkArgument;%0Aimport static java.lang.String.format;%0A%0A
 public c
@@ -1191,176 +1191,751 @@
 per(
-%22%22 + failedBenchmarkResults.size() + %22 benchmarks failed%22
+createMessage(failedBenchmarkResults));%0A        this.failedBenchmarkResults = failedBenchmarkResults;%0A        this.benchmarksCount = benchmarksCount;%0A%0A        failedBenchmarkResults.stream()%0A                .flatMap(benchmarkExecutionResult -%3E benchmarkExecutionResult.getFailureCauses().stream())%0A                .forEach(this::addSuppressed
 );%0A    
+%7D%0A%0A
     
-this.failedBenchmarkResults = failedBenchmarkResults;%0A        this.benchmarksCount = benchmarksCount
+private static String createMessage(List%3CBenchmarkExecutionResult%3E failedBenchmarkResults)%0A    %7B%0A        checkArgument(!failedBenchmarkResults.isEmpty(), %22no failures%22);%0A%0A        return format(%22%25s benchmarks failed, first failure was: %25s%22,%0A                failedBenchmarkResults.size(),%0A                Iterables.getFirst(failedBenchmarkResults.get(0).getFailureCauses(), null)%0A        )
 ;%0A  

Make FailedBenchmarkExecutionException's message more useful