public function onException(GetResponseForExceptionEvent $event)
    {
        if (!$this->isApplicable($event->getRequest())) {
            return;
        }

        $response = $this->convert($event->getException());

        $event->setResponse($response);
    }
public function onException(GetResponseForExceptionEvent $event)
    {
        if (!$this->isApplicable($event->getRequest())) {
            return;
        }

        $response = $this->convert($event->getException());

        $event->setResponse($response);
    }
public function onException ( GetResponseForExceptionEvent $ event ) { if ( ! $ this -> isApplicable ( $ event -> getRequest ( ) ) ) { return ; } $ response = $ this -> convert ( $ event -> getException ( ) ) ; $ event -> setResponse ( $ response ) ; }
Listen for exceptions and convert them to JSON responses if necessary.

@param GetResponseForExceptionEvent $event
Listen for exceptions and convert them to JSON responses if necessary .