Skip to content

Commit 76ec2e2

Browse files
committed
Merge pull request #15 from Flowpack/catch-cleanup-error
[TASK] Gracefully handle errors in nodeindex:cleanup
2 parents e82cace + 830f2c7 commit 76ec2e2

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

Classes/Flowpack/ElasticSearch/ContentRepositoryAdaptor/Command/NodeIndexCommandController.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,19 @@ public function buildCommand($limit = NULL, $update = FALSE) {
141141
* @return void
142142
*/
143143
public function cleanupCommand() {
144-
$indicesToBeRemoved = $this->nodeIndexer->removeOldIndices();
145-
146-
if (count($indicesToBeRemoved) > 0) {
147-
foreach ($indicesToBeRemoved as $indexToBeRemoved) {
148-
$this->logger->log('Removing old index ' . $indexToBeRemoved);
144+
try {
145+
$indicesToBeRemoved = $this->nodeIndexer->removeOldIndices();
146+
if (count($indicesToBeRemoved) > 0) {
147+
foreach ($indicesToBeRemoved as $indexToBeRemoved) {
148+
$this->logger->log('Removing old index ' . $indexToBeRemoved);
149+
}
150+
} else {
151+
$this->logger->log('Nothing to remove.');
149152
}
150-
} else {
151-
$this->logger->log('Nothing to remove.');
153+
} catch (\Flowpack\ElasticSearch\Transfer\Exception\ApiException $exception) {
154+
$response = json_decode($exception->getResponse());
155+
$this->logger->log(sprintf('Nothing removed. ElasticSearch responded with status %s, saying "%s"', $response->status, $response->error));
152156
}
157+
153158
}
154159
}

0 commit comments

Comments
 (0)