Skip to content

Commit 5459f0d

Browse files
committed
Add proper error handler to backend config
1 parent 2155cf4 commit 5459f0d

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

backend/config/components.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
'request' => [
99
'cookieValidationKey' => file_get_contents(__DIR__ . '/cookie-validation.key'),
1010
],
11-
11+
'errorHandler' => [
12+
'errorAction' => 'site/error',
13+
],
1214
'urlManager' => [
1315
'enablePrettyUrl' => true,
1416
'enableStrictParsing' => true,

backend/controllers/SiteController.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,22 @@
33
namespace backend\controllers;
44

55
use yii\web\Controller;
6+
use yii\web\ErrorAction;
67

78
/**
89
*
910
*/
1011
class SiteController extends Controller
1112
{
13+
public function actions()
14+
{
15+
return array_merge(parent::actions(), [
16+
'error' => [
17+
'class' => ErrorAction::class,
18+
],
19+
]);
20+
}
21+
1222
public function actionIndex()
1323
{
1424
return $this->render('index');

0 commit comments

Comments
 (0)