77
88package org .elasticsearch .xpack .inference .action .filter ;
99
10- import org .elasticsearch .ElasticsearchException ;
1110import org .elasticsearch .ElasticsearchStatusException ;
1211import org .elasticsearch .ExceptionsHelper ;
1312import org .elasticsearch .ResourceNotFoundException ;
4645import org .elasticsearch .xcontent .XContent ;
4746import org .elasticsearch .xpack .core .XPackField ;
4847import org .elasticsearch .xpack .core .inference .results .ChunkedInferenceError ;
48+ import org .elasticsearch .xpack .inference .InferenceException ;
4949import org .elasticsearch .xpack .inference .mapper .SemanticTextField ;
5050import org .elasticsearch .xpack .inference .mapper .SemanticTextFieldMapper ;
5151import org .elasticsearch .xpack .inference .mapper .SemanticTextUtils ;
@@ -290,14 +290,12 @@ public void onFailure(Exception exc) {
290290 request .field
291291 );
292292 } else {
293- failure = exc instanceof ElasticsearchException
294- ? exc
295- : new ElasticsearchException (
296- "Error loading inference for inference id [{}] on field [{}]" ,
297- exc ,
298- inferenceId ,
299- request .field
300- );
293+ failure = new InferenceException (
294+ "Error loading inference for inference id [{}] on field [{}]" ,
295+ exc ,
296+ inferenceId ,
297+ request .field
298+ );
301299 }
302300 inferenceResults .get (request .index ).failures .add (failure );
303301 }
@@ -321,14 +319,12 @@ public void onResponse(List<ChunkedInference> results) {
321319 var acc = inferenceResults .get (request .index );
322320 if (result instanceof ChunkedInferenceError error ) {
323321 acc .addFailure (
324- error .exception () instanceof ElasticsearchException
325- ? error .exception ()
326- : new ElasticsearchException (
327- "Exception when running inference id [{}] on field [{}]" ,
328- error .exception (),
329- inferenceProvider .model .getInferenceEntityId (),
330- request .field
331- )
322+ new InferenceException (
323+ "Exception when running inference id [{}] on field [{}]" ,
324+ error .exception (),
325+ inferenceProvider .model .getInferenceEntityId (),
326+ request .field
327+ )
332328 );
333329 } else {
334330 acc .addOrUpdateResponse (
@@ -355,14 +351,12 @@ public void onFailure(Exception exc) {
355351 for (FieldInferenceRequest request : requests ) {
356352 addInferenceResponseFailure (
357353 request .index ,
358- exc instanceof ElasticsearchException
359- ? exc
360- : new ElasticsearchException (
361- "Exception when running inference id [{}] on field [{}]" ,
362- exc ,
363- inferenceProvider .model .getInferenceEntityId (),
364- request .field
365- )
354+ new InferenceException (
355+ "Exception when running inference id [{}] on field [{}]" ,
356+ exc ,
357+ inferenceProvider .model .getInferenceEntityId (),
358+ request .field
359+ )
366360 );
367361 }
368362 } finally {
0 commit comments