Commit 80cb3e71 by Alexander Makarov

added example of using try-catch to hanle errors

parent 150d5152
......@@ -2,9 +2,26 @@ Error Handling
==============
Error handling in Yii is different than handling errors in plain PHP. First of all, Yii will convert all non-fatal errors
to *exceptions*. By doing so, you can gracefully handle them using `try`-`catch`. Second, even fatal errors in Yii are
rendered in a nice way. This means that in debugging mode, you can trace the causes of fatal errors in order to more quickly
identify the cause of the problem.
to *exceptions*:
```php
use yii\base\ErrorException;
use Yii;
try {
10/0;
} catch (ErrorException) {
Yii::warning("Tried dividing by zero.");
}
// execution may continue
```
As demonstrated above you may handle errors using `try`-`catch`.
Second, even fatal errors in Yii are rendered in a nice way. This means that in debugging mode, you can trace the causes
of fatal errors in order to more quickly identify the cause of the problem.
Rendering errors in a dedicated controller action
-------------------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment