Example #1
0
 public function run()
 {
     if (Yii::$app->response->format == Response::FORMAT_HTML) {
         if ($this->debug || null === $this->exceptionView) {
             $file = $this->errorHandler->exceptionView;
             $this->response->data = $this->errorHandler->renderFile($file, ['exception' => $this->exception]);
             return $this->response;
         } else {
             return $this->controller->render($this->exceptionView, ['exception' => $this->exception]);
         }
     }
     if ($this->exception instanceof HttpException) {
         $code = $this->exception->statusCode;
     } elseif ($this->exception instanceof ResultsException || $this->exception instanceof UserException) {
         $code = $this->exception->getCode();
     } else {
         $code = 500;
     }
     if ($this->exception instanceof ResultsException) {
         $isSuccess = $this->exception->isSuccess;
     } else {
         $isSuccess = false;
     }
     $data = $this->exception instanceof ResultsException ? $this->exception->data : null;
     if ($this->debug) {
         $debugBacktrace = $this->convertExceptionToArray($this->exception);
     } else {
         $debugBacktrace = null;
     }
     return $this->controller->formatResults($code, $data, $isSuccess, $debugBacktrace, $this->exception->getMessage());
 }