简体   繁体   中英

can you customise the maximum execution time error message

is it possible to have a customised Maximum execution time so instead of showing

PHP Fatal Error – yii\base\ErrorException

Maximum execution time of 30 seconds exceeded

and then showing all the code on the error page, I'd like it to take you to a customised error page saying something like "you need to add some search criteria to reduce the number of records being returned"

or some such thing. I am working with Yii2 and PHP

I have the following action in my site controller

public function actions()
{
    return [
        'error' => [
            'class' => 'yii\web\ErrorAction',
        ],
        'captcha' => [
            'class' => 'yii\captcha\CaptchaAction',
            'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null,
        ],
    ];
}

and I have a page called views/site/error.php

<div class="alert alert-danger" style="font-size: 14pt; text-align: center;">
    <?= nl2br(Html::encode($message)) ?>
</div>

<p>
    Please contact Client Support team if you think this is an error with our servers.
</p>

<?= Html::a('Back', Yii::$app->request->referrer, ['class' => 'btn btn-info']) ?>
<?= Html::a('Home', ['/'], ['class' => 'btn btn-success']) ?>

but if never goes to this page with an execution time error

Not sure what I did, but it does go to the custom error page now but it still shows the code below my custom message

在此处输入图像描述

so is there a way of getting rid of the information below my custom message. There is nothing else on my error.php than what is in the code above

after further investigation, I've found that it was going to a different page execption.php not error.php which was showing the full error below the text. So I've managed to sort it now:)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM