Skip to content

Commit

Permalink
Added more output when errors occured during execute command (#49)
Browse files Browse the repository at this point in the history
* Added more output when errors occured during execute command

* Apply suggestions from code review

Co-Authored-By: jbcr <51637606+jbcr@users.noreply.github.com>
  • Loading branch information
jeremycr and jbcr authored Feb 27, 2020
1 parent bd9171a commit a5518c8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Added CollectionWriter and DelegatorWriter
* Adding Symfony 5.0 compatibility
* Save all exceptions caught in the log for `code-rhapsodie:dataflow:execute`
* Added more output when errors occured during `code-rhapsodie:dataflow:execute`

# Version 2.0.2

Expand Down
14 changes: 8 additions & 6 deletions src/Command/ExecuteDataflowCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ class ExecuteDataflowCommand extends Command
/** @var ConnectionFactory */
private $connectionFactory;

/**
* @var LoggerInterface
*/
/** @var LoggerInterface */
private $logger;

public function __construct(DataflowTypeRegistryInterface $registry, ConnectionFactory $connectionFactory, LoggerInterface $logger)
Expand Down Expand Up @@ -79,11 +77,15 @@ protected function execute(InputInterface $input, OutputInterface $output)
$output->writeln('End time: '.$result->getEndTime()->format('Y/m/d H:i:s'));
$output->writeln('Success: '.$result->getSuccessCount());

if ($result->hasErrors()> 0)
{
if ($result->hasErrors() > 0) {
$output->writeln('<error> Errors: '.$result->getErrorCount().' </error>');
$output->writeln('<error> Exceptions traces are available in the logs. </error>');

foreach ($result->getExceptions() as $e) {
$this->logger->error('Error during processing : '.$e->getMessage(), ['exception'=>$e]);
$this->logger->error('Error during processing : '.$e->getMessage(), ['exception' => $e]);
}

return 1;
}

return 0;
Expand Down

0 comments on commit a5518c8

Please sign in to comment.