Exceptions and ZE2

From: Date: Mon, 01 Oct 2001 14:29:02 +0000
Subject: Exceptions and ZE2
Groups: php.dev 
Request: Send a blank email to php-dev+get-66919@lists.php.net to get a copy of this message
i've looked at the latest Zend CVS and like what i see with regards to exceptions, and i'd like to make a suggestion. in other languages (c++, delphi and Java for sure), you can specify the type of exception you are interested in in the catch block. short of this, the programmer would have to check nearly every exception value returned and rethrow if she cannot handle it try { barf(); } catch ($url) { if ( is_subclass_of($url,'badFoodException') ) { echo "shoulda had a beer"; } else throw ($url); } instead of try { barf(); } catch(badFoodException $url) { echo "shoulda had a beer" /* all other exceptions are propagated */ } in the aformentioned languages (Python also), it implies that there is a system defined base exception class from which all other exceptions descend. this is not a bad idea, although an internal subclass check would work irrespective of the type of value thrown. Delphi works this way - you can throw any object, though by convention you'd throw a subclass of the EException class. l0-t3k

« previous php.dev (#66919) next »