1 | <?php |
||
2 | |||
0 ignored issues
–
show
Coding Style
introduced
by
![]() |
|||
3 | namespace DMT\Insolvency\Exception; |
||
4 | |||
5 | use DMT\CommandBus\Validator\ValidationException; |
||
6 | use DMT\Insolvency\Http\Request\GetReport; |
||
7 | use DMT\Insolvency\Http\Response\GetReportResponse; |
||
8 | use DMT\Insolvency\Soap\Request; |
||
9 | use DMT\Insolvency\Soap\Response; |
||
10 | use JMS\Serializer\Exception\Exception as SerializerException; |
||
11 | use League\Tactician\Middleware; |
||
12 | use Psr\Http\Client\ClientExceptionInterface; |
||
13 | |||
14 | /** |
||
15 | * Class ExceptionMiddleware |
||
16 | */ |
||
0 ignored issues
–
show
|
|||
17 | class ExceptionMiddleware implements Middleware |
||
18 | { |
||
19 | /** |
||
0 ignored issues
–
show
|
|||
20 | * @param Request|GetReport $command |
||
0 ignored issues
–
show
|
|||
21 | * @param callable $next |
||
0 ignored issues
–
show
|
|||
22 | * @return Response|GetReportResponse |
||
0 ignored issues
–
show
|
|||
23 | * @throws Exception |
||
0 ignored issues
–
show
|
|||
24 | */ |
||
25 | 16 | public function execute($command, callable $next) |
|
26 | { |
||
27 | try { |
||
28 | /** @var Response|GetReportResponse $response */ |
||
0 ignored issues
–
show
|
|||
29 | 16 | return $next($command); |
|
30 | 5 | } catch (Exception $exception) { |
|
31 | 2 | throw $exception; |
|
32 | 3 | } catch (ClientExceptionInterface $exception) { |
|
33 | 1 | throw new UnavailableException($exception->getMessage(), 0, $exception); |
|
34 | 2 | } catch (ValidationException $exception) { |
|
35 | 1 | throw new RequestException($exception->getMessage(), 0, $exception); |
|
36 | 1 | } catch (SerializerException $exception) { |
|
37 | 1 | throw new UnavailableException($exception->getMessage(), 0, $exception); |
|
38 | } |
||
39 | } |
||
40 | } |
||
41 |