Skip to content

Commit 55d3499

Browse files
committed
TASK: Report error in CLI output during the build command
1 parent 736e356 commit 55d3499

1 file changed

Lines changed: 19 additions & 8 deletions

File tree

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

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
* source code.
1212
*/
1313

14+
use Flowpack\ElasticSearch\ContentRepositoryAdaptor\Indexer\Error\ErrorInterface;
1415
use Flowpack\ElasticSearch\ContentRepositoryAdaptor\Mapping\NodeTypeMappingBuilder;
16+
use Flowpack\ElasticSearch\ContentRepositoryAdaptor\Service\ErrorHandlingService;
1517
use Flowpack\ElasticSearch\ContentRepositoryAdaptor\Service\IndexWorkspaceTrait;
1618
use TYPO3\Flow\Annotations as Flow;
1719
use TYPO3\Flow\Cli\CommandController;
@@ -25,6 +27,12 @@ class NodeIndexCommandController extends CommandController
2527
{
2628
use IndexWorkspaceTrait;
2729

30+
/**
31+
* @Flow\Inject
32+
* @var ErrorHandlingService
33+
*/
34+
protected $errorHandlingService;
35+
2836
/**
2937
* @Flow\Inject
3038
* @var \Flowpack\ElasticSearch\ContentRepositoryAdaptor\Indexer\NodeIndexer
@@ -165,13 +173,6 @@ public function buildCommand($limit = null, $update = false, $workspace = null,
165173
$workspace = 'live';
166174
}
167175

168-
$callback = function ($workspaceName, $indexedNodes, $dimensions) {
169-
if ($dimensions === []) {
170-
$this->outputLine('Workspace "' . $workspaceName . '" without dimensions done. (Indexed ' . $indexedNodes . ' nodes)');
171-
} else {
172-
$this->outputLine('Workspace "' . $workspaceName . '" and dimensions "' . json_encode($dimensions) . '" done. (Indexed ' . $indexedNodes . ' nodes)');
173-
}
174-
};
175176
if ($workspace === null) {
176177
foreach ($this->workspaceRepository->findAll() as $workspace) {
177178
$count += $this->indexWorkspace($workspace->getName(), $limit, $callback);
@@ -182,7 +183,17 @@ public function buildCommand($limit = null, $update = false, $workspace = null,
182183

183184
$this->nodeIndexingManager->flushQueues();
184185

185-
$this->logger->log('Done. (indexed ' . $count . ' nodes)', LOG_INFO);
186+
if ($this->errorHandlingService->hasError()) {
187+
$this->outputLine();
188+
/** @var ErrorInterface $error */
189+
foreach ($this->errorHandlingService as $error) {
190+
$this->outputLine('<error>Error</error> ' . $error->message());
191+
}
192+
$this->outputLine();
193+
$this->outputLine('<error>Check your logs for more informations</error>');
194+
} else {
195+
$this->logger->log('Done. (indexed ' . $count . ' nodes)', LOG_INFO);
196+
}
186197
$this->nodeIndexer->getIndex()->refresh();
187198

188199
// TODO: smoke tests

0 commit comments

Comments
 (0)