0
我有一個控制器「前」,我只想讓此控制器使用自定義錯誤操作。 我該怎麼做?我試圖this,但它似乎並不工作控制器的自定義錯誤處理程序,yii2
我有一個控制器「前」,我只想讓此控制器使用自定義錯誤操作。 我該怎麼做?我試圖this,但它似乎並不工作控制器的自定義錯誤處理程序,yii2
我發現這個解決方案來捕獲異常
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
]);