Skip to content

Commit

Permalink
handle exceptions on LoggableMigrations
Browse files Browse the repository at this point in the history
  • Loading branch information
mmadariaga committed Aug 11, 2022
1 parent 52c2d81 commit 169cfdb
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions Infrastructure/Persistence/Doctrine/LoggableMigration.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,28 @@ abstract class LoggableMigration extends AbstractMigration

public function postUp(Schema $schema): void
{
$this->logChanges('up');
$this->logChangesAndHandleErrors('up');
parent::postUp(...func_get_args());
}

public function postDown(Schema $schema): void
{
$this->logChanges('down');
$this->logChangesAndHandleErrors('down');
parent::postDown(...func_get_args());
}

private function logChangesAndHandleErrors(string $direction)
{
try {
$this->logChanges($direction);
} catch (\Exception $e) {
$this->warnIf(
true,
$e->getMessage()
);
}
}

private function logChanges(string $direction)
{
$event = new CommandWasExecuted(
Expand Down Expand Up @@ -76,7 +88,6 @@ private function logChanges(string $direction)
}
}


/**
* @param string $entity
* @param array $commandData
Expand Down

0 comments on commit 169cfdb

Please sign in to comment.