public function onException(GetResponseForExceptionEvent $exceptionEvent)
 {
     $exception = $exceptionEvent->getException();
     if (isset($this->app['json.exception.handler'])) {
         $response = $this->app['json.exception.handler']($exception, $this->app);
     } else {
         $response = ErrorHandler::jsonExceptionError($exception, $this->app['appName']);
     }
     $exceptionEvent->setResponse($response);
 }
 public function onRequestStart(GetResponseEvent $responseEvent)
 {
     $request = $responseEvent->getRequest();
     $jsonContent = $request->getContent();
     if (empty($jsonContent)) {
         return;
     }
     $parser = new JsonParser();
     $result = $parser->lint($jsonContent);
     if ($result instanceof ParsingException) {
         $appPrefix = null;
         if (is_callable(array($this->app, "getClientName"))) {
             $appPrefix = ucwords($this->app->getClientName());
         }
         if (is_callable(array($this->app, "getAppName"))) {
             $appPrefix = ucwords($this->app->getAppName());
         }
         /**
          * @todo make use configurable DI injected error handler provider
          */
         $responseEvent->setResponse(ErrorHandler::jsonExceptionError($result, $appPrefix));
     }
 }