Handling failures

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:
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