Yii2 how to handle the exception?

Good afternoon.

How to handle exceptions, such as \SoapFault that the application continued working as though nothing happened?

Now I understand the method yii\base\ErrorHandler::register() put error handlers, which leads to undesirable results.
As a crutch I found a solution, and only works for the controller of the heir to the \yii\web\Controller, for yii\console\Controller exception could not be prevented in any way. In General I don't like it, something I'm missing completely obvious.
try {
Yii::$app->errorHandler->unregister();
 $this->_soapClient = new \SoapClient($this->wsdl,
array(
 'trace' => 1,
 'exceptions' => 1,
 'encoding' => 'UTF-8',
 'passphrase' => "
)
);
}
 catch(\SoapFault $e) {
 Yii::$app->errorHandler->exception->type = null;
Yii::$app->errorHandler->register();
 }


As a variant I see details tradebait this component to inherit it and figure out your way out of the situation, but I am sure that this model will need to be addressed somehow much easier and more graceful. And the need is 1m in behavior, not in all application.
September 19th 19 at 13:28
1 answer
September 19th 19 at 13:30
What does the ErrorHandler? ErrorHandler is triggered only those exceptions that you yourself are not caught in try..catch.
If you handle the exception, you may continue the application to work as if nothing happened.
Here's an example:

try {
 throw new \Exception('Error!');
} catch (\Exception $ex) {
}

//...You can continue the application as if there were no exceptions
Well almost, still need to disable xdebug as it turned out, a trace error which I mentioned added to it!:) Well, error_reporting off.
But how to overcome register_shutdown_function([$this, 'handleFatalError']); not yet invented. - Theodore_Blick commented on September 19th 19 at 13:33

Find more questions by tags YiiExceptions