Skip to content

Commit

Permalink
Add method name to error message
Browse files Browse the repository at this point in the history
  • Loading branch information
ddrv committed Apr 18, 2021
1 parent 985052c commit 2b8774e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
3 changes: 3 additions & 0 deletions Slim/CallableResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ private function resolveSlimNotation(string $toResolve): array
$instance = $this->container->get($class);
} else {
if (!class_exists($class)) {
if ($method) {
$class .= '::' . $method . '()';
}
throw new RuntimeException(sprintf('Callable %s does not exist', $class));
}
$instance = new $class($this->container);
Expand Down
12 changes: 6 additions & 6 deletions tests/CallableResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ public function testMiddlewareFunctionNotFoundThrowException()
public function testClassNotFoundThrowException()
{
$this->expectException(RuntimeException::class);
$this->expectExceptionMessage('Callable Unknown does not exist');
$this->expectExceptionMessage('Callable Unknown::notFound() does not exist');

/** @var ContainerInterface $container */
$container = $this->containerProphecy->reveal();
Expand All @@ -486,7 +486,7 @@ public function testClassNotFoundThrowException()
public function testRouteClassNotFoundThrowException()
{
$this->expectException(RuntimeException::class);
$this->expectExceptionMessage('Callable Unknown does not exist');
$this->expectExceptionMessage('Callable Unknown::notFound() does not exist');

/** @var ContainerInterface $container */
$container = $this->containerProphecy->reveal();
Expand All @@ -497,7 +497,7 @@ public function testRouteClassNotFoundThrowException()
public function testMiddlewareClassNotFoundThrowException()
{
$this->expectException(RuntimeException::class);
$this->expectExceptionMessage('Callable Unknown does not exist');
$this->expectExceptionMessage('Callable Unknown::notFound() does not exist');

/** @var ContainerInterface $container */
$container = $this->containerProphecy->reveal();
Expand All @@ -508,7 +508,7 @@ public function testMiddlewareClassNotFoundThrowException()
public function testCallableClassNotFoundThrowException()
{
$this->expectException(RuntimeException::class);
$this->expectExceptionMessage('Callable Unknown does not exist');
$this->expectExceptionMessage('Callable Unknown::notFound() does not exist');

/** @var ContainerInterface $container */
$container = $this->containerProphecy->reveal();
Expand All @@ -519,7 +519,7 @@ public function testCallableClassNotFoundThrowException()
public function testRouteCallableClassNotFoundThrowException()
{
$this->expectException(RuntimeException::class);
$this->expectExceptionMessage('Callable Unknown does not exist');
$this->expectExceptionMessage('Callable Unknown::notFound() does not exist');

/** @var ContainerInterface $container */
$container = $this->containerProphecy->reveal();
Expand All @@ -530,7 +530,7 @@ public function testRouteCallableClassNotFoundThrowException()
public function testMiddlewareCallableClassNotFoundThrowException()
{
$this->expectException(RuntimeException::class);
$this->expectExceptionMessage('Callable Unknown does not exist');
$this->expectExceptionMessage('Callable Unknown::notFound() does not exist');

/** @var ContainerInterface $container */
$container = $this->containerProphecy->reveal();
Expand Down

0 comments on commit 2b8774e

Please sign in to comment.