1
votes

I'm working on Yii2 advanced application project and I have a problem with yii2 built-in Error Handler. Here is description of my problem:

I have set errorAction in my backend configuration in this way:

'errorHandler' => [
    'errorAction' => 'site/error',
],

Now, the method actionError() in the SiteController catches every application exceptions, user defined exceptions and also fatal errors, except database related exception such as yii\db\IntegrityException. I don't know why, but when such an exception occurs, actionError() does not do anything! I don't want to catch exception manually with try-catch block and I want the central ErrorHandler catches all exception.

How can I fix this problem? Thank you all specially yii experts for paying attention. Please help me to solve this strange problem.

1
Did you disabled YII_DEBUG? - Yupik
@Yupik No, It has true value. - hamed
Change it, should be fixed. - Yupik

1 Answers

0
votes

According to this GitHub issue: yiisoft/yii2/issues/10657 and to the comment made by @Yupik you must change the YII_DEBUG.

If YII_DEBUG is true, you should see proper message about yii\db\IntegrityException in debug mode.

If YII_DEBUG is false(like in a production enviroment) error is redirected to actionError() and see it in a user-friendly mode.