Yii2 - error handler can not catches database exceptions

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.

So, how do you know there was an error, actually - what is the behavior of an application?

Default error page of application with stacktrace. I want to actionError() method catch the exception

I know you said you don’t want to catch the exception locally, but I would say you should catch it and throw an exception that can be caught by errorHandler.

Edit: I don’t know if you know what was the purpose to implement an IntegrityException basically the idea is to avoid row check against database if it throws you can catch and retry or abort.