Skip to content

Commit

Permalink
More meaningful message for user
Browse files Browse the repository at this point in the history
  • Loading branch information
mabar committed Oct 2, 2018
1 parent 7e36060 commit f7215a9
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/Dispatcher/CoreDispatcher.php
Expand Up @@ -49,7 +49,7 @@ protected function handle(ServerRequestInterface $request, ResponseInterface $re

// Validate if response is ResponseInterface
if (!($response instanceof ResponseInterface)) {
throw new InvalidStateException(sprintf('Handler returned response must implement "%s"', ResponseInterface::class));
throw new InvalidStateException(sprintf('Endpoint returned response must implement "%s"', ResponseInterface::class));
}

return $response;
Expand Down
2 changes: 1 addition & 1 deletion src/Dispatcher/DecoratedDispatcher.php
Expand Up @@ -116,7 +116,7 @@ protected function handle(ServerRequestInterface $request, ResponseInterface $re

// Validate if response is ResponseInterface
if (!($response instanceof ResponseInterface)) {
throw new InvalidStateException(sprintf('Handler returned response must implement "%s"', ResponseInterface::class));
throw new InvalidStateException(sprintf('Endpoint returned response must implement "%s"', ResponseInterface::class));
}

try {
Expand Down
2 changes: 1 addition & 1 deletion src/Dispatcher/JsonDispatcher.php
Expand Up @@ -26,7 +26,7 @@ protected function handle(ServerRequestInterface $request, ResponseInterface $re

// Validate if response is ResponseInterface
if (!($response instanceof ResponseInterface)) {
throw new InvalidStateException(sprintf('Handler returned response must implement "%s"', ResponseInterface::class));
throw new InvalidStateException(sprintf('Endpoint returned response must implement "%s"', ResponseInterface::class));
}

return $response;
Expand Down
2 changes: 1 addition & 1 deletion tests/cases/Dispatcher/CoreDispatcher.phpt
Expand Up @@ -35,7 +35,7 @@ test(function (): void {

Assert::exception(function () use ($dispatcher, $request, $response): void {
$dispatcher->dispatch($request, $response);
}, InvalidStateException::class, sprintf('Handler returned response must implement "%s"', ResponseInterface::class));
}, InvalidStateException::class, sprintf('Endpoint returned response must implement "%s"', ResponseInterface::class));
});

// Request not matched, throw exception
Expand Down
2 changes: 1 addition & 1 deletion tests/cases/Dispatcher/DecoratedDispatcher.phpt
Expand Up @@ -64,7 +64,7 @@ test(function (): void {

Assert::exception(function () use ($dispatcher, $request, $response): void {
$dispatcher->dispatch($request, $response);
}, InvalidStateException::class, sprintf('Handler returned response must implement "%s"', ResponseInterface::class));
}, InvalidStateException::class, sprintf('Endpoint returned response must implement "%s"', ResponseInterface::class));
});

// Match request, use invalid handler, throw exception
Expand Down
2 changes: 1 addition & 1 deletion tests/cases/Dispatcher/JsonDispatcher.phpt
Expand Up @@ -47,7 +47,7 @@ test(function (): void {
$dispatcher = new JsonDispatcher(new FakeRouter(true), new FakeNullHandler());
Assert::exception(function () use ($dispatcher, $request, $response): void {
$dispatcher->dispatch($request, $response);
}, InvalidStateException::class, sprintf('Handler returned response must implement "%s"', ResponseInterface::class));
}, InvalidStateException::class, sprintf('Endpoint returned response must implement "%s"', ResponseInterface::class));
});

// Not matched, use fallback, write error to response body
Expand Down

0 comments on commit f7215a9

Please sign in to comment.