Skip to content

Commit

Permalink
Rename JsonApiErrorHandlerMiddleware to JsonApiExceptionHandlerMiddle…
Browse files Browse the repository at this point in the history
…ware
  • Loading branch information
kocsismate committed Feb 2, 2018
1 parent 6ee4b5a commit ad213b5
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ ADDED:

CHANGED:

- `JsonApiErrorHandlerMiddleware` expects a `ResponseInterface` instance as the first constructor parameter to use it as an error response prototype
- `JsonApiErrorHandlerMiddleware` catches and handles `Throwable`s by default
- `JsonApiErrorHandlerMiddleware` was renamed to `JsonApiExceptionHandlerMiddleware`
- `JsonApiExceptionHandlerMiddleware` expects a `ResponseInterface` instance as the first constructor parameter to use it as an error response prototype
- `JsonApiExceptionHandlerMiddleware` catches and handles `Throwable`s by default
- `JsonApiDispatcherMiddleware` throws an exception instead of responding with an error 404 response if it can not find any dispatchable action
- PHPUnit 7 is minimally required to run tests

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ used (e.g.: when dispatching fails)
- `handlerAttribute`: The name of the request attribute which stores a dispatchable controller (it is usually
provided by a router).

### JsonApiErrorHandlerMiddleware
### JsonApiExceptionHandlerMiddleware

It catches exceptions and responds with an appropriate JSON:API error response.

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use WoohooLabs\Yin\JsonApi\Serializer\SerializerInterface;
use WoohooLabs\YinMiddleware\Exception\RequestException;

class JsonApiErrorHandlerMiddleware implements MiddlewareInterface
class JsonApiExceptionHandlerMiddleware implements MiddlewareInterface
{
/**
* @var ResponseInterface
Expand Down
10 changes: 5 additions & 5 deletions tests/Middleware/JsonApiErrorHandlerMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Psr\Http\Server\RequestHandlerInterface;
use WoohooLabs\Yin\JsonApi\Exception\DefaultExceptionFactory;
use WoohooLabs\Yin\JsonApi\Request\Request;
use WoohooLabs\YinMiddleware\Middleware\JsonApiErrorHandlerMiddleware;
use WoohooLabs\YinMiddleware\Middleware\JsonApiExceptionHandlerMiddleware;
use WoohooLabs\YinMiddleware\Tests\Utils\DummyException;
use Zend\Diactoros\Response;
use Zend\Diactoros\ServerRequest;
Expand All @@ -21,7 +21,7 @@ class JsonApiErrorHandlerMiddlewareTest extends TestCase
*/
public function exceptionWhenNotCatching()
{
$middleware = new JsonApiErrorHandlerMiddleware($this->createResponse(), false, false);
$middleware = new JsonApiExceptionHandlerMiddleware($this->createResponse(), false, false);

$this->expectException(DummyException::class);
$middleware->process($this->createRequest(), $this->createHandler());
Expand All @@ -32,7 +32,7 @@ public function exceptionWhenNotCatching()
*/
public function responseWhenException()
{
$middleware = new JsonApiErrorHandlerMiddleware($this->createResponse(), true, false);
$middleware = new JsonApiExceptionHandlerMiddleware($this->createResponse(), true, false);

$response = $middleware->process($this->createRequest(), $this->createHandler());

Expand All @@ -44,7 +44,7 @@ public function responseWhenException()
*/
public function notVerboseResponseWhenException()
{
$middleware = new JsonApiErrorHandlerMiddleware($this->createResponse(), true, false);
$middleware = new JsonApiExceptionHandlerMiddleware($this->createResponse(), true, false);

$response = $middleware->process($this->createRequest(), $this->createHandler());

Expand All @@ -56,7 +56,7 @@ public function notVerboseResponseWhenException()
*/
public function verboseResponseWhenException()
{
$middleware = new JsonApiErrorHandlerMiddleware($this->createResponse(), true, true);
$middleware = new JsonApiExceptionHandlerMiddleware($this->createResponse(), true, true);

$response = $middleware->process($this->createRequest(), $this->createHandler());
$body = json_decode($response->getBody()->__toString(), true);
Expand Down

0 comments on commit ad213b5

Please sign in to comment.