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