Skip to content

Commit 9574d06

Browse files
committed
Add ErrorMiddleware to TestAsset
1 parent a04e42a commit 9574d06

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace HttpSoft\Tests\Basis\TestAsset;
6+
7+
use HttpSoft\Basis\Exception\HttpException;
8+
use Psr\Http\Message\ResponseInterface;
9+
use Psr\Http\Message\ServerRequestInterface;
10+
use Psr\Http\Server\MiddlewareInterface;
11+
use Psr\Http\Server\RequestHandlerInterface;
12+
13+
class ErrorMiddleware implements MiddlewareInterface
14+
{
15+
/**
16+
* @var HttpException
17+
*/
18+
private HttpException $exception;
19+
20+
/**
21+
* @param HttpException $exception
22+
*/
23+
public function __construct(HttpException $exception)
24+
{
25+
$this->exception = $exception;
26+
}
27+
28+
/**
29+
* @param ServerRequestInterface $request
30+
* @param RequestHandlerInterface $handler
31+
* @return ResponseInterface
32+
* @throws HttpException
33+
*/
34+
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
35+
{
36+
throw $this->exception;
37+
}
38+
}

0 commit comments

Comments
 (0)