Check searchresponse is success or failure for a given search

I am querying elasticsearch with the below query

SearchResponse searchResponse = getElasticSearchClient()
.prepareSearch(indexNameStr).setTypes(typeNameStr)
.setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
.setQuery(queryStrr).setSize(size)
.setFrom(start).addSort(fieldSortBuilder)
.execute().actionGet();

I wanted to check if the search is success or failure. Catch exception If there are any during search.

Is it correct to use below method to identify failures in search;

public void parseSearchResultFailures(SearchResponse res) {
    if (res.getFailedShards() > 0) {
        final ShardSearchFailure[] shardFailures = res.getShardFailures();
        StringBuilder reasonBuilder = new StringBuilder();
        for (ShardSearchFailure failure : shardFailures) {
            final String reason = failure.reason();
            LOGGER.info("Status: " + failure.status()
                    + " - Search failed on shard: " + reason);
            reasonBuilder.append(reason);
        }
        throw new ElasticsearchException("Search failed: "
                + reasonBuilder.toString());
    }
}

Thanks,

Hi Vipins,
I would start with checking the HTTP request status.
Whenever there's an error, the actionGet will throw an exception.
So I would do something like:

SearchResponse result = null;
try{
result = esRequest.execute().actionGet();
if(result.status().equals(RestStatus.OK)){
//handle success
}
else{
log.error("something unexpected accured");
parseSearchResultFailures(result);
}

}catch(ElasticsearchException e){
//handle Exception
log.error(e.getMessage());
}