All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ai.vespa.feed.client.MultiFeedException Maven / Gradle / Ivy

There is a newer version: 8.443.12
Show newest version
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package ai.vespa.feed.client;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * Aggregates multiple instances of {@link FeedException}
 *
 * @author bjorncs
 */
public class MultiFeedException extends RuntimeException {

    private final List exceptions;

    public MultiFeedException(Collection exceptions) {
        super(toMessage(exceptions));
        this.exceptions = Collections.unmodifiableList(new ArrayList<>(exceptions));
    }

    public Collection feedExceptions() { return exceptions; }

    public Set documentIds() {
        return exceptions.stream()
                .filter(e -> e.documentId().isPresent())
                .map(e -> e.documentId().get())
                .collect(Collectors.toSet());
    }

    private static String toMessage(Collection exceptions) {
        return String.format("%d feed operations failed", exceptions.size());
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy