public function onKernelException(GetResponseForExceptionEvent $e)
 {
     $ex = $e->getException();
     $response = new Response();
     if ($ex instanceof NotFoundHttpException) {
         $response->setContent($this->view->render('error/404'));
         $e->setResponse($response);
         return;
     }
     if ($this->debugMode) {
         \Symfony\Component\Debug\ExceptionHandler::register();
         throw $ex;
     }
     $response->setContent($this->view->render('error/exception'));
     $e->setResponse($response);
     $this->logger->handleException($ex);
 }
Esempio n. 2
0
 /**
  * Handles an exception
  *
  * @param \Exception $e The exception to handle
  */
 public function handleException(\Exception $e)
 {
     if ($e instanceof ValidatorException) {
         $this->logger->log($this->uncaughtExceptionLevel === null ? LogLevel::ERROR : $this->uncaughtExceptionLevel, $e->getMessage(), []);
     } else {
         $this->monologHandler->handleException($e);
     }
     if ($this->previousExceptionHandler) {
         call_user_func($this->previousExceptionHandler, $e);
     }
 }