Skip to content

Commit c15cd1b

Browse files
committed
Removing the more generic exception since no other implementation needed it
1 parent 15d800c commit c15cd1b

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/datafeed/DatafeedConfig.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import org.apache.logging.log4j.LogManager;
1010
import org.apache.logging.log4j.Logger;
1111
import org.elasticsearch.ElasticsearchException;
12+
import org.elasticsearch.ElasticsearchStatusException;
1213
import org.elasticsearch.TransportVersion;
1314
import org.elasticsearch.action.search.SearchRequest;
1415
import org.elasticsearch.action.support.IndicesOptions;
@@ -21,6 +22,7 @@
2122
import org.elasticsearch.core.TimeValue;
2223
import org.elasticsearch.core.Tuple;
2324
import org.elasticsearch.index.query.QueryBuilder;
25+
import org.elasticsearch.rest.RestStatus;
2426
import org.elasticsearch.search.aggregations.AggregationBuilder;
2527
import org.elasticsearch.search.aggregations.AggregatorFactories;
2628
import org.elasticsearch.search.aggregations.bucket.composite.CompositeAggregationBuilder;
@@ -1051,7 +1053,7 @@ public DatafeedConfig build() {
10511053
indicesOptions = IndicesOptions.STRICT_EXPAND_OPEN_HIDDEN_FORBID_CLOSED;
10521054
}
10531055
if (indicesOptions.resolveCrossProjectIndexExpression()) {
1054-
throw ExceptionsHelper.crossProjectSearchIsDisabled();
1056+
throw new ElasticsearchStatusException("Cross-project search is not enabled for Datafeeds", RestStatus.FORBIDDEN);
10551057
}
10561058

10571059
return new DatafeedConfig(

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/utils/ExceptionsHelper.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,6 @@ public static ElasticsearchStatusException taskOperationFailureToStatusException
101101
return new ElasticsearchStatusException(failure.getCause().getMessage(), failure.getStatus(), failure.getCause());
102102
}
103103

104-
public static ElasticsearchStatusException crossProjectSearchIsDisabled() {
105-
return new ElasticsearchStatusException("Cross-project search is not enabled for any ML feature", RestStatus.FORBIDDEN);
106-
}
107-
108104
/**
109105
* Creates an error message that explains there are shard failures, displays info
110106
* for the first failure (shard/reason) and kindly asks to see more info in the logs

x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/datafeed/DatafeedConfigBuilderTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public void testResolveCrossProjectIsDisabled() {
159159
);
160160

161161
var actualException = assertThrows(ElasticsearchStatusException.class, datafeedBuilder::build);
162-
assertThat(actualException.getMessage(), equalTo("Cross-project search is not enabled for any ML feature"));
162+
assertThat(actualException.getMessage(), equalTo("Cross-project search is not enabled for Datafeeds"));
163163
assertThat(actualException.status(), equalTo(RestStatus.FORBIDDEN));
164164
}
165165

0 commit comments

Comments
 (0)