From 54b45b38c6f9721eb70acfa096871d95a393e92c Mon Sep 17 00:00:00 2001 From: Daniel Subiabre Date: Wed, 18 Dec 2024 15:57:10 +0100 Subject: [PATCH] Update match strategy locator error handling --- src/Matchfunding/MatchStrategy/MatchStrategyLocator.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Matchfunding/MatchStrategy/MatchStrategyLocator.php b/src/Matchfunding/MatchStrategy/MatchStrategyLocator.php index bda41f9..71ae51b 100644 --- a/src/Matchfunding/MatchStrategy/MatchStrategyLocator.php +++ b/src/Matchfunding/MatchStrategy/MatchStrategyLocator.php @@ -19,7 +19,7 @@ public function __construct( if (\array_key_exists($strategyName, $this->strategiesByName)) { throw new \Exception(\sprintf( - "Duplicate strategy name '%s' by '%s', value already in use by '%s'", + "Duplicate MatchStrategy name '%s' by '%s', value already in use by '%s'", $strategyName, $strategy::class, $this->strategiesByName[$strategyName]::class @@ -33,7 +33,10 @@ public function __construct( public function get(string $strategyName): ?MatchStrategyInterface { if (!array_key_exists($strategyName, $this->strategiesByName)) { - return null; + throw new \Exception(\sprintf( + "Could not find a MatchStrategy by the name '%s', value does not exist", + $strategyName + )); } return $this->strategiesByName[$strategyName];