I’m giving a look at kohanaphp, and I was perplexed by the internal management of errors. When you initialize the framework, Kohana gives you the ability to disable the internal management of errors. When enabled, all errors (NOTICE, WARNING, etc..) are converted into using ErrorException exceptions. (http://php.net/manual/en/class.errorexception.php)
Kohana makes large use this system to detect errors generated by php, in the form of exceptions.
Example:
try
{
$this->_connection = mysql_connect($hostname, $username, $password, TRUE);
}
catch (ErrorException $e)
{
// error connection.
throw new Database_Exception(':error', array(':error' => mysql_error()), mysql_errno());
}
My question is: if I disable error handling of Kohan, there is a risk of corrupting the business logic? And if so, why Kohana makes it possible to disable? Or is there something that escapes me?
According to you this way of handling errors native php correct?
What martswite said only applies to the 2.* release. Turning off the error flag in the 3.* releases is not recommend as you’ll get normal PHP errors.
If you’re using a try catch to see if MySQL would connect, then yes.
That is something I’ve put to the developers (http://dev.kohanaframework.org/issues/4017). I don’t see any reason for it to be around in the 3.* release so you’re not the only one who is a tad confused.
Yes, I prefer wrapping something that could fail in a try … catch over prepending @ to the front of the method. It’s cleaner and more inline with how other programming languages work.