/**
* Error action
*
* @return void
*/
public function actionError()
{
$exception = Yii::$app->errorHandler->exception;
// Error route
switch ($exception->statusCode) {
case 404:
$this->layout = 'empty';
return $this->render('error_404', ['exception' => $exception]);
break;
default:
$this->redirect('/');
break;
}
}
Last active
August 1, 2018 05:36
-
-
Save yidas/0bcf11a3d43f7f909bc750f63af089c6 to your computer and use it in GitHub Desktop.
[Yii2] Yii2 sample code of Error Action handling such 404 errors
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment