Skip to content
This repository was archived by the owner on Dec 11, 2023. It is now read-only.

Commit 24a44a3

Browse files
mangelsncrgomezcasas
authored andcommitted
Ignore exceptions caused by non-handled events (#13)
This is useful when you queue more than one event, and there's no handlers associated to the one event. In the older behaviour, the next events to a non-handled event are not handled because the triggered exception. With this modification, the non-handled event don't block the next events execution
1 parent 96bc4bf commit 24a44a3

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Shared/Infrastructure/Bus/Event/InMemory/InMemorySymfonyEventBus.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ public function __construct(iterable $subscribers)
3131

3232
public function publish(DomainEvent ...$events): void
3333
{
34-
try {
35-
foreach ($events as $event) {
34+
foreach ($events as $event) {
35+
try {
3636
$this->bus->dispatch($event);
37-
}
38-
} catch (NoHandlerForMessageException $error) {}
37+
} catch (NoHandlerForMessageException $error) {}
38+
}
3939
}
4040
}

0 commit comments

Comments
 (0)