Conditions | 3 |
Paths | 3 |
Total Lines | 18 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 3.0067 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
22 | 5 | public function onKernelException(GetResponseForExceptionEvent $event) |
|
23 | { |
||
24 | 5 | $exception = $event->getException(); |
|
25 | 5 | if ($exception instanceof JsonHttpException) { |
|
26 | $errorData = [ |
||
27 | 'error' => [ |
||
28 | 5 | 'code' => $exception->getStatusCode(), |
|
29 | 5 | 'message' => $exception->getMessage(), |
|
30 | ], |
||
31 | ]; |
||
32 | 5 | if (($data = $exception->getData())) { |
|
33 | $errorData['error']['fields'] = $data; |
||
34 | } |
||
35 | 5 | $response = new JsonResponse($errorData); |
|
36 | 5 | $event->setResponse($response); |
|
37 | 5 | $this->logger->error($exception->getMessage(), $errorData); |
|
38 | } |
||
39 | 5 | } |
|
40 | } |
||
41 |