Best practice concerning Exceptions

From: Date: Wed, 10 Mar 2010 14:37:46 +0000
Subject: Best practice concerning Exceptions
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-30390@lists.php.net to get a copy of this message
Hi, I've found the XML_RPC2 package (only after writing my own version of it ofcourse :( ..) and noticed that it declares quite a number of different exception classes. I've read the 'Error Handling Guidelines for PHP5 Packages' but couldn't find any information on when to use a new Exception class and when simply to use a new code and message. What is considered good practice for PHP5 exceptions? My own code uses just two exception classes, with about 8 different codes and messages. It seems the XML_RPC2 package throws a specific exception class for each error, skipping error codes. I understand that specific exception classes make it easier to catch just those types of error, but I'm not sure when to create a new exception class and when not to. Somehow the number of different exceptions defined in XML_RPC2 (15) seems excessive to me. regards, Auke van Slooten Muze

« previous php.pear.general (#30390) next »