How to save errors with the handleError in CakePHP 2.0?
Posted
by
jags1988cr
on Stack Overflow
See other posts from Stack Overflow
or by jags1988cr
Published on 2012-10-03T15:35:33Z
Indexed on
2012/10/03
15:37 UTC
Read the original article
Hit count: 170
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...
© Stack Overflow or respective owner