#28033 [Opn->Bgs]: try-catch doesnt really catch ?

From: Date: Sat, 17 Apr 2004 07:46:15 +0000
Subject: #28033 [Opn->Bgs]: try-catch doesnt really catch ?
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-58290@lists.php.net to get a copy of this message
ID: 28033 Updated by: derick@php.net Reported By: phil at adigital dot com dot mx -Status: Open +Status: Bogus Bug Type: Zend Engine 2 problem Operating System: linux red hat PHP Version: 5.0.0RC1 New Comment: Expected behavior. Normal errors are NOT exceptions and will therefore not be caught. Only thrown exceptions (extended fromthe Exception class) will be real exceptions, all usually errors (E_WARNING, E_NOTICE and E_ERROR) will not (as they are not exceptions). Previous Comments: ------------------------------------------------------------------------ [2004-04-17 02:29:39] phil at adigital dot com dot mx Description: ------------ It seems that try-catch only catch the exception that USER program into its code with a throw... I hope this is a transitional state, since the most usefull and interesting catches that you can get are definitively "WARNINGS" and "FATAL ERRORS" taht PHP itself can give. see example below I hope all PHP functions (i-e- Zend 2 engine) will be able to catch WARNINGS and FATAL ERRORS somehow, or said on other words, that any PHP functions will use Throw *any exceptions* Thx Reproduce code: --------------- error_reporting(E_ALL); try { print $variable_not_set; // syntax error eval $toeval = "print \"Hola exec 1;"; eval($toeval); $toeval = "print \$not_set_variable;"; eval($toeval); } catch (Exception $exception) { echo "CATCHED EXCEPTION: ".$exception; } Expected result: ---------------- this is supposed to catch the warning of non existing variable, the syntax error of evaluated expresion and the warning of not set variable into evaluate expresion. It doesn't catch anything ! (cf: Java does !) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=28033&edit=1

« previous php.bugs (#58290) next »