Skip to content

Commit

Permalink
[CronJob] Integrate DoctrineEnvelopeEntityReference custom exception
Browse files Browse the repository at this point in the history
  • Loading branch information
mpoiriert committed Dec 13, 2024
1 parent bcb00c8 commit 4a1b6d2
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/cron-job/Message/ExecuteCronJobMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@

use Draw\Component\CronJob\Entity\CronJobExecution;
use Draw\Component\Messenger\AutoStamp\Message\StampingAwareInterface;
use Draw\Component\Messenger\DoctrineEnvelopeEntityReference\Exception\ObjectNotFoundException;
use Draw\Component\Messenger\DoctrineEnvelopeEntityReference\Message\DoctrineReferenceAwareInterface;
use Draw\Component\Messenger\DoctrineEnvelopeEntityReference\Stamp\PropertyReferenceStamp;
use Symfony\Component\Messenger\Bridge\Amqp\Transport\AmqpStamp;
use Symfony\Component\Messenger\Envelope;
use Symfony\Component\Messenger\Exception\UnrecoverableMessageHandlingException;

class ExecuteCronJobMessage implements DoctrineReferenceAwareInterface, StampingAwareInterface
{
private ?CronJobExecution $execution;
private PropertyReferenceStamp|CronJobExecution|null $execution;

public function __construct(CronJobExecution $execution)
{
Expand All @@ -22,8 +23,8 @@ public function __construct(CronJobExecution $execution)

public function getExecution(): CronJobExecution
{
if (null === $this->execution) {
throw new UnrecoverableMessageHandlingException('CronJobExecution is not set.');
if (!$this->execution instanceof CronJobExecution) {
throw new ObjectNotFoundException(CronJobExecution::class, $this->execution);
}

return $this->execution;
Expand Down

0 comments on commit 4a1b6d2

Please sign in to comment.