# Handling failures

**URL:** <https://discuss.elastic.co/t/handling-failures/9893>\
**Category:** Elasticsearch\
**Created:** [November 29, 2012, 5:42pm UTC](https://discuss.elastic.co/t/handling-failures/9893 "2012-11-29T17:42:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Henrik\_Nordvik](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/henrik_nordvik/32/1096_2.png) [@Henrik\_Nordvik](https://discuss.elastic.co/u/Henrik_Nordvik)\
**Post date:** [November 29, 2012, 5:42pm UTC](https://discuss.elastic.co/t/handling-failures/9893/1 "2012-11-29T17:42:37Z")

</div>

I do a batch index requests, and iterate through the response like this:

```
    for (BulkItemResponse itemResponse : bulkResponse) {
        if (itemResponse.isFailed()) {
            // What should I do here
        }
    }

```

Say if I get this error: "Failed bulk item:  
UnavailableShardsException[[com.mycompany.app][0] [1] shardIt, [0] active :  
Timeout waiting for [1m], request:  
org.elasticsearch.action.bulk.BulkShardRequest@10f0082]"  
In that case I want to stop/pause my indexer and try again later. How do I  
check which failure reason I get programmatically? I can only see the  
failure message as a string. Do I need to inspect the contents of this  
string?

--

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 3:02am UTC](https://discuss.elastic.co/t/handling-failures/9893/2 "2017-07-06T03:02:06Z")

</div>


