| 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 | 1 | public function onKernelException(GetResponseForExceptionEvent $event) |
|
| 23 | { |
||
| 24 | 1 | $exception = $event->getException(); |
|
| 25 | 1 | if ($exception instanceof JsonHttpException) { |
|
| 26 | $errorData = [ |
||
| 27 | 'error' => [ |
||
| 28 | 1 | 'code' => $exception->getStatusCode(), |
|
| 29 | 1 | 'message' => $exception->getMessage(), |
|
| 30 | ] |
||
| 31 | ]; |
||
| 32 | 1 | if (($data = $exception->getData())) { |
|
| 33 | $errorData['error']['fields'] = $data; |
||
| 34 | } |
||
| 35 | 1 | $response = new JsonResponse($errorData); |
|
| 36 | 1 | $event->setResponse($response); |
|
| 37 | 1 | $this->logger->error($exception->getMessage(), $errorData); |
|
| 38 | } |
||
| 39 | 1 | } |
|
| 40 | } |
||
| 41 |