<?php
/**
* User: broasca
* Date: 06.05.2021
* Time: 15:48
*/
namespace App\EventListener;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
class ExceptionListener
{
public function onKernelException(ExceptionEvent $event)
{
// // todo change in production
//
// // You get the exception object from the received event
// $exception = $event->getThrowable();
// $data = [
// 'success' => false,
// 'code' => $exception->getCode(),
// 'message' => $exception->getMessage(),
// ];
//
// // Customize your response object to display the exception details
// $response = new Response();
// $response->setContent(json_encode($data));
//
// // HttpExceptionInterface is a special type of exception that
// // holds status code and header details
// if ($exception instanceof HttpExceptionInterface) {
// $response->setStatusCode($exception->getStatusCode());
// $response->headers->replace($exception->getHeaders());
// } else {
// $response->setStatusCode(Response::HTTP_INTERNAL_SERVER_ERROR);
// }
//
// // sends the modified response object to the event
// $event->setResponse($response);
}
}