unknown exception error in php
- by fayer
i wanna catch all exceptions thrown in a script and then check if they have a error code 23000.
if they don't i want to rethrow the exception.
here is my code:
function myException($exception) {
/*** If it is a Doctrine Connection Mysql Duplication Exception ***/
if(get_class($exception) === 'Doctrine_Connection_Mysql_Exception' && $exception->getCode() === 23000) {
echo "Duplicate entry";
} else {
throw $exception;
}
}
set_exception_handler('myException');
$contact = new Contact();
$contact->email = 'peter';
$contact->save();
but i get this error message and i dont know what it means:
Fatal error: Exception thrown without a stack frame in Unknown on line 0
i want to be able to rethrow the original error message if it has not the error code 23000.
even when i deleted the check errorcode i still get the same message:
function myException($exception) {
throw $exception;
}
set_exception_handler('myException');
$contact = new Contact();
$contact->email = 'peter';
$contact->save();
how could i solve this?
thanks