Re: error handling

From: Date: Thu, 13 Sep 2007 01:30:14 +0000
Subject: Re: error handling
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-48014@lists.php.net to get a copy of this message
On 9/8/07, Bill Shupp <hostmaster@shupp.org> wrote: > Hi Folks, > > I'm trying to finish up a new package, and am having some difficulty > with proper error handling. I see that PEAR_Error is deprecated in > favor of PEAR_Exception. But exceptions seem to be overkill for some > of the things I used to use PEAR_Error for, such as passing around > error codes and messages as return values from methods. > > For example, in this context, my class talks to a tcp daemon that may > return an error code and string for a command, but it's not something > I'd want to throw an exception for in my class. Rather, it would be > handy to pass back an error object like PEAR_Error. But will using > it in this manner keep the package from being compliant with PEAR > error handling guidelines, and perhaps not accepted? Is there > another way to handle this that I'm not considering? > No PEAR_Error usage is allowed in new packages. All error handling is to be done with PEAR_Exception. If you're just passing things around internally the it will never be thrown outside of the package you could maybe just return a simple assoc array but I would suggest instead using PEAR_Exception for any real errors and having any code that handles such things catcht he exceptions and keep processing from there. -- Justin Patrin

« previous php.pear.dev (#48014) next »