From bb6932e92ec41a8f48fd4233865ae6534700e8e5 Mon Sep 17 00:00:00 2001 From: fadrian06 Date: Sat, 15 Aug 2026 14:34:38 -0400 Subject: [PATCH] throw OutOfBoundsException instead of Exception when event name hasn't been set --- flight/core/Dispatcher.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/flight/core/Dispatcher.php b/flight/core/Dispatcher.php index eb176b7..e60b015 100644 --- a/flight/core/Dispatcher.php +++ b/flight/core/Dispatcher.php @@ -7,6 +7,7 @@ namespace flight\core; use Exception; use flight\Engine; use InvalidArgumentException; +use OutOfBoundsException; use Psr\Container\ContainerInterface as Container; use ReflectionFunction; use Throwable; @@ -74,7 +75,8 @@ class Dispatcher * @param string $name Event name. * @param mixed[] $params Event callable parameters. * @return mixed Output of event callable. - * @throws Throwable If event name isn't found or if event throws an `Throwable`. + * @throws Throwable If the callable or its filters throw an `Throwable`. + * @throws OutOfBoundsException If callable name is not found. */ public function run(string $name, array $params = []) { @@ -104,14 +106,15 @@ class Dispatcher * @param array &$params * * @return void|mixed - * @throws Exception + * @throws Throwable If the callable or its filters throw an `Throwable`. + * @throws OutOfBoundsException If callable name is not found. */ protected function runEvent(string $eventName, array &$params) { $requestedMethod = $this->get($eventName); if ($requestedMethod === null) { - throw new Exception("Event '$eventName' isn't found."); + throw new OutOfBoundsException("Event '$eventName' isn't found."); } return $this->execute($requestedMethod, $params);