How to save errors with the handleError in CakePHP 2.0?
- by jags1988cr
I have a big problem. Well, I'm trying to save the errors that happen in my web application. For example (only a example), if I make a division by zero, or happens an error in a query or something like that. So, I wanna catch that and save it in the database. But the handleError of CakePHP is static, so I can't use $this-MyModel-saveError(...).
In my /app/Lib/AppError.php I have this:
class AppError extends ErrorHandler
{
public $uses = array('Errors.Error');
public static function handleError($code, $description, $file = null, $line = null, $context = null)
{
//This print the error:
echo "Code: ".$code." Description: ".$description." File: ".$file." Line: ".$line."<br>";
//I want to do this, (save to the database):
$this->Error->saveError($code, $description, $file, $line);
}
}
Without the $this-Error-saveError($code, $description, $file, $line); it works but I not only want to show the error.
I think need an example or something like that. Please help me.
Regards and thank you.
Thanks...
P.D.: Sorry for the English, I'm an english student...