2016-12-21 55 views

回答

1

我发现这个解决方案来捕获异常

if ($model == null) { 
    // (I want the front layout only for this exception,so this 'throw' seems not to working as I want,it has the 'site' layout of site/error default error action)throw new NotFoundHttpException('The patient does not exist.'); 
      $exception = new \yii\web\NotFoundHttpException("The patient does not exist"); 
      $statusCode = $exception->statusCode; 
      $name = $exception->getName(); 
      $message = $exception->getMessage(); 
      return $this->render('error', [ 
         'exception' => $exception, 
         'statusCode' => $statusCode, 
         'name' => $name, 
         'message' => $message 
      ]); 
相关问题