/**
  * Forwards an exception to Whoops.
  * @param Exception $exception
  */
 protected function handleException($exception)
 {
     if ($exception instanceof CHttpException && $this->errorAction !== null || !YII_DEBUG) {
         parent::handleException($exception);
         return;
     }
     $this->disableLogRoutes();
     $this->whoops->handleException($exception);
 }
 /**
  * Forwards an exception to Whoops.
  * @param Exception $exception
  */
 protected function handleException($exception)
 {
     if ($this->beforeHandling($exception)) {
         if (!headers_sent()) {
             $code = $exception instanceof CHttpException ? $exception->statusCode : 500;
             $msg = $this->getHttpHeader($code, get_class($exception));
             header("{$_SERVER['SERVER_PROTOCOL']} {$code} {$msg}");
         }
         if ($exception instanceof CHttpException || !YII_DEBUG) {
             parent::render('error', $exception);
         } else {
             if ($this->isAjaxRequest()) {
                 Yii::app()->displayException($exception);
             } else {
                 if ($this->errorAction) {
                     Yii::app()->runController($this->errorAction);
                 }
                 if (!$this->handled) {
                     $this->whoops->handleException($exception);
                 }
             }
         }
     }
 }