diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/utils/ExceptionsHelper.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/utils/ExceptionsHelper.java index 267566dcf365e..fb75d95aeed1b 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/utils/ExceptionsHelper.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/utils/ExceptionsHelper.java @@ -20,6 +20,9 @@ public class ExceptionsHelper { + private static String NO_KNOWN_MODEL_ERROR = + "No known trained model with model_id [{}], you may need to create it or load it into the cluster with eland"; + private ExceptionsHelper() {} public static ResourceNotFoundException missingJobException(String jobId) { @@ -51,19 +54,11 @@ public static ResourceNotFoundException missingModelDeployment(String deployment } public static ResourceNotFoundException missingTrainedModel(String modelId) { - return new ResourceNotFoundException( - "No known trained model with model_id [{}], you may need to create it or load it into the cluster with eland", - modelId - ); + return new ResourceNotFoundException(NO_KNOWN_MODEL_ERROR, modelId); } public static ResourceNotFoundException missingTrainedModel(String modelId, Exception cause) { - return new ResourceNotFoundException( - "Failure due to [{}]. No known trained model with model_id [{}], " - + "you may need to create it or load it into the cluster with eland", - cause, - modelId - ); + return new ResourceNotFoundException(NO_KNOWN_MODEL_ERROR, cause, modelId); } public static ElasticsearchException serverError(String msg) {