aboutsummaryrefslogtreecommitdiffstats
path: root/container-search/src/main/java/com/yahoo/search/grouping/UnavailableAttributeException.java
blob: 5655a4c57c97ec87924675a434a234f2485348d9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.grouping;

/**
 * This exception is thrown by the {@link GroupingValidator} if it a {@link GroupingRequest} contains a reference to an
 * unavailable attribute.
 *
 * @author Simon Thoresen Hult
 */
@SuppressWarnings("serial")
public class UnavailableAttributeException extends RuntimeException {

    private final String clusterName;
    private final String attributeName;

    /**
     * Constructs a new instance of this class.
     *
     * @param clusterName   The name of the cluster for which the request is illegal.
     * @param attributeName The name of the attribute which is referenced but not available.
     */
    public UnavailableAttributeException(String clusterName, String attributeName) {
        super("Grouping request references attribute '" + attributeName + "' which is not available " +
              "in cluster '" + clusterName + "'.");
        this.clusterName = clusterName;
        this.attributeName = attributeName;
    }

    /**
     * Returns the name of the cluster for which the request is illegal.
     *
     * @return The cluster name.
     */
    public String getClusterName() {
        return clusterName;
    }

    /**
     * Returns the name of the attribute which is referenced but not available.
     *
     * @return The attribute name.
     */
    public String getAttributeName() {
        return attributeName;
    }
}