94
94
import org .elasticsearch .search .SearchHits ;
95
95
import org .elasticsearch .search .aggregations .Aggregation ;
96
96
import org .reactivestreams .Publisher ;
97
-
98
97
import org .springframework .data .elasticsearch .client .ClientConfiguration ;
99
98
import org .springframework .data .elasticsearch .client .ClientLogger ;
100
99
import org .springframework .data .elasticsearch .client .ElasticsearchHost ;
113
112
import org .springframework .util .Assert ;
114
113
import org .springframework .util .ObjectUtils ;
115
114
import org .springframework .util .ReflectionUtils ;
116
- import org .springframework .web .client .HttpServerErrorException ;
117
115
import org .springframework .web .reactive .function .BodyExtractors ;
118
116
import org .springframework .web .reactive .function .client .ClientRequest ;
119
117
import org .springframework .web .reactive .function .client .ClientResponse ;
@@ -806,9 +804,10 @@ private static XContentParser createParser(String mediaType, String content) thr
806
804
807
805
private <T > Publisher <? extends T > handleServerError (Request request , ClientResponse response ) {
808
806
809
- return Mono .error (
810
- new HttpServerErrorException (response .statusCode (), String .format ("%s request to %s returned error code %s." ,
811
- request .getMethod (), request .getEndpoint (), response .statusCode ().value ())));
807
+ RestStatus status = RestStatus .fromCode (response .statusCode ().value ());
808
+
809
+ return Mono .error (new ElasticsearchStatusException (String .format ("%s request to %s returned error code %s." ,
810
+ request .getMethod (), request .getEndpoint (), response .statusCode ().value ()), status ));
812
811
}
813
812
814
813
private <T > Publisher <? extends T > handleClientError (String logId , Request request , ClientResponse response ,
@@ -828,8 +827,7 @@ private <T> Publisher<? extends T> handleClientError(String logId, Request reque
828
827
return Mono .error (new ElasticsearchStatusException (sb .toString (), status , exception ));
829
828
}
830
829
} catch (Exception e ) {
831
- return Mono
832
- .error (new ElasticsearchStatusException (content , status ));
830
+ return Mono .error (new ElasticsearchStatusException (content , status ));
833
831
}
834
832
return Mono .just (content );
835
833
}).doOnNext (it -> ClientLogger .logResponse (logId , response .statusCode (), it )) //
0 commit comments