private function cleanupRenameFailure(Client $client, $indexName, \Exception $renameAliasException)
    {
        $additionalError = '';
        try {
            $this->deleteIndex($client, $indexName);
        } catch (ExceptionInterface $deleteNewIndexException) {
            $additionalError = sprintf(
                'Tried to delete newly built index %s, but also failed: %s',
                $indexName,
                $deleteNewIndexException->getMessage()
            );
        }

        throw new \RuntimeException(sprintf(
            'Failed to updated index alias: %s. %s',
            $renameAliasException->getMessage(),
            $additionalError ?: sprintf('Newly built index %s was deleted', $indexName)
        ), 0, $renameAliasException);
    }
private function cleanupRenameFailure(Client $client, $indexName, \Exception $renameAliasException)
    {
        $additionalError = '';
        try {
            $this->deleteIndex($client, $indexName);
        } catch (ExceptionInterface $deleteNewIndexException) {
            $additionalError = sprintf(
                'Tried to delete newly built index %s, but also failed: %s',
                $indexName,
                $deleteNewIndexException->getMessage()
            );
        }

        throw new \RuntimeException(sprintf(
            'Failed to updated index alias: %s. %s',
            $renameAliasException->getMessage(),
            $additionalError ?: sprintf('Newly built index %s was deleted', $indexName)
        ), 0, $renameAliasException);
    }
private function cleanupRenameFailure ( Client $ client , $ indexName , \ Exception $ renameAliasException ) { $ additionalError = '' ; try { $ this -> deleteIndex ( $ client , $ indexName ) ; } catch ( ExceptionInterface $ deleteNewIndexException ) { $ additionalError = sprintf ( 'Tried to delete newly built index %s, but also failed: %s' , $ indexName , $ deleteNewIndexException -> getMessage ( ) ) ; } throw new \ RuntimeException ( sprintf ( 'Failed to updated index alias: %s. %s' , $ renameAliasException -> getMessage ( ) , $ additionalError ? : sprintf ( 'Newly built index %s was deleted' , $ indexName ) ) , 0 , $ renameAliasException ) ; }
Cleans up an index when we encounter a failure to rename the alias.

@param Client     $client
@param string     $indexName
@param \Exception $renameAliasException
Cleans up an index when we encounter a failure to rename the alias .