Conditions | 5 |
Paths | 5 |
Total Lines | 20 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
33 | private function dispatch($message) |
||
34 | { |
||
35 | if (!$this->messageBus instanceof MessageBusInterface) { |
||
36 | throw new \InvalidArgumentException('The message bus is not set.'); |
||
37 | } |
||
38 | |||
39 | if (!class_exists(HandlerFailedException::class)) { |
||
40 | return $this->messageBus->dispatch($message); |
||
41 | } |
||
42 | |||
43 | try { |
||
44 | return $this->messageBus->dispatch($message); |
||
45 | } catch (HandlerFailedException $e) { |
||
46 | // unwrap the exception thrown in handler for Symfony Messenger >= 4.3 |
||
47 | while ($e instanceof HandlerFailedException) { |
||
48 | /** @var \Throwable $e */ |
||
49 | $e = $e->getPrevious(); |
||
50 | } |
||
51 | |||
52 | throw $e; |
||
53 | } |
||
56 |