Skip to content

Commit 2b8774e

Browse files
committed
Add method name to error message
1 parent 985052c commit 2b8774e

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

Slim/CallableResolver.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ private function resolveSlimNotation(string $toResolve): array
146146
$instance = $this->container->get($class);
147147
} else {
148148
if (!class_exists($class)) {
149+
if ($method) {
150+
$class .= '::' . $method . '()';
151+
}
149152
throw new RuntimeException(sprintf('Callable %s does not exist', $class));
150153
}
151154
$instance = new $class($this->container);

tests/CallableResolverTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ public function testMiddlewareFunctionNotFoundThrowException()
475475
public function testClassNotFoundThrowException()
476476
{
477477
$this->expectException(RuntimeException::class);
478-
$this->expectExceptionMessage('Callable Unknown does not exist');
478+
$this->expectExceptionMessage('Callable Unknown::notFound() does not exist');
479479

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

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

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

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

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

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

0 commit comments

Comments
 (0)