diff --git a/src/LQDN/CommandHandler.php b/src/LQDN/CommandHandler.php index 11f5184b0a4169ccc5e96d877a60313422017ca4..52eabda0b70d4b36f069e92852b0c015e2b7e2f5 100644 --- a/src/LQDN/CommandHandler.php +++ b/src/LQDN/CommandHandler.php @@ -19,7 +19,11 @@ class CommandHandler */ public function handle($command) { - $method = $this->getHandleMethod($command); + try { + $method = $this->getHandleMethod($command); + } catch (Exception $e) { + throw new CommandNotHandledException(); + } foreach ($this->handlers as $handler) { if (method_exists($handler, $method)) { diff --git a/tests/functional/Handler/CommandHandlerTest.php b/tests/functional/Handler/CommandHandlerTest.php index 77870602d4fb057a1506ec558f764685fdab5267..4871cf1966e8c2ac59777dbe21397b511126dfb5 100644 --- a/tests/functional/Handler/CommandHandlerTest.php +++ b/tests/functional/Handler/CommandHandlerTest.php @@ -16,7 +16,7 @@ class CommandHandlerTest extends Functionaltest public function testCommandNotHandledException() { $this->setExpectedException('LQDN\Exception\CommandNotHandledException'); - $this->container['command_handler']->handle(new Object()); + $this->container['command_handler']->handle(new class{}); } }