Tuesday, July 3, 2012

Using exceptions in YII framework

Exceptions are a core PHP feature, but they are seldom used fairly. Yii makes exceptions
very useful.
There are two main areas where Yii exceptions come in handy, which are as follows:
1. Exceptions allow simplifying the process of detecting and fixing application errors and
special situations, such as database connection failure or API failure.
2. Exceptions allow generating different HTTP responses in a very clean way.
Generally, an exception should be thrown when a component cannot handle a special
situation, such as the one said earlier, and needs to leave it to higher-level components.

No comments:

Post a Comment