Skip to content

Commit

Permalink
replace dump output with own implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidBadura committed Dec 14, 2023
1 parent 92ea207 commit d0d8f66
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Console/Command/ProjectionStatusCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Throwable;

use function array_map;
use function dump;

#[AsCommand(
'event-sourcing:projection:status',
Expand Down Expand Up @@ -91,8 +91,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int

$errorObject = $projection->errorObject();

if ($errorObject) {
dump($errorObject);
if ($errorObject instanceof Throwable) {
$io->throwable($errorObject);
}

return 0;
Expand Down
16 changes: 16 additions & 0 deletions src/Console/OutputStyle.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
use Patchlevel\EventSourcing\Serializer\Encoder\Encoder;
use Patchlevel\EventSourcing\Serializer\EventSerializer;
use Symfony\Component\Console\Style\SymfonyStyle;
use Throwable;

use function sprintf;

final class OutputStyle extends SymfonyStyle
{
Expand Down Expand Up @@ -37,4 +40,17 @@ public function message(EventSerializer $serializer, Message $message): void

$this->block($data->payload);
}

public function throwable(Throwable $error): void
{
$number = 1;

do {
$this->error(sprintf('%d) %s', $number, $error->getMessage()));
$this->block($error->getTraceAsString());

$number++;
$error = $error->getPrevious();
} while ($error !== null);
}
}

0 comments on commit d0d8f66

Please sign in to comment.