i bir komut atılan tüm özel durumları yakalamak istiyorum ve onlar bir hata kodu 23000 varsa o kontrol edin.
onlar yoksa ben istisna rethrow istiyorum.
İşte benim kod:
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();
ama bu hata mesajı alıyorum ve ben bunun ne anlama geldiğini bilmiyorum:
Fatal error: Exception thrown without a stack frame in Unknown on line 0
i hata kodu 23000 değil varsa orijinal hata iletisini rethrow edebilmek istiyorum.
i çek errorCode silinmiş olsa bile ben yine aynı mesajı alıyorum:
function myException($exception) {
throw $exception;
}
set_exception_handler('myException');
$contact = new Contact();
$contact->email = 'peter';
$contact->save();
Bu nasıl çözebilir?
teşekkürler