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
]);