Skip to content

Commit 53936fb

Browse files
Narrowing exception
1 parent f1f29af commit 53936fb

File tree

1 file changed

+5
-1
lines changed
  • x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/custom

1 file changed

+5
-1
lines changed

x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/custom/CustomService.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
package org.elasticsearch.xpack.inference.services.custom;
99

10+
import org.apache.logging.log4j.LogManager;
11+
import org.apache.logging.log4j.Logger;
1012
import org.elasticsearch.ElasticsearchStatusException;
1113
import org.elasticsearch.TransportVersion;
1214
import org.elasticsearch.TransportVersions;
@@ -52,8 +54,10 @@
5254
import static org.elasticsearch.xpack.inference.services.ServiceUtils.throwUnsupportedUnifiedCompletionOperation;
5355

5456
public class CustomService extends SenderService {
57+
5558
public static final String NAME = "custom";
5659
private static final String SERVICE_NAME = "Custom";
60+
private static final Logger logger = LogManager.getLogger(CustomService.class);
5761

5862
private static final EnumSet<TaskType> supportedTaskTypes = EnumSet.of(
5963
TaskType.TEXT_EMBEDDING,
@@ -114,7 +118,7 @@ private static void validateConfiguration(CustomModel model) {
114118

115119
try {
116120
new CustomRequest(query, List.of("test input"), model).createHttpRequest();
117-
} catch (Exception e) {
121+
} catch (IllegalStateException e) {
118122
var validationException = new ValidationException();
119123
validationException.addValidationError(Strings.format("Failed to validate model configuration: %s", e.getMessage()));
120124
throw validationException;

0 commit comments

Comments
 (0)