From 298ee988ea4d50057b81fda09f97d4052ed2574d Mon Sep 17 00:00:00 2001 From: Toby Twigger Date: Sun, 27 Jun 2021 23:06:55 +0100 Subject: [PATCH] Throw an exception if the event has no listeners --- src/Command/Command.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Command/Command.php b/src/Command/Command.php index 3cbbf83..9bd51a2 100644 --- a/src/Command/Command.php +++ b/src/Command/Command.php @@ -2,6 +2,7 @@ namespace OriginEngine\Command; +use Illuminate\Support\Facades\Event; use OriginEngine\Contracts\Feature\FeatureRepository; use OriginEngine\Contracts\Feature\FeatureResolver; use OriginEngine\Contracts\Pipeline\PipelineRunner; @@ -84,6 +85,10 @@ public function getSubscribedSignals(): array public function handleSignal(int $signal): void { event(new SignalReceived($signal)); + + if(!Event::hasListeners(SignalReceived::class)) { + throw new \Exception(sprintf('Signal %u encountered, stopping.', $signal)); + } } }