Re: Call for Review: RFC for Error Handling in PHP5 packages
| From: | Lukas Smith | Date: | Fri, 06 Aug 2004 18:18:07 +0000 |
| Subject: | Re: Call for Review: RFC for Error Handling in PHP5 packages | ||
| References: | 1 2 3 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-32496@lists.php.net to get a copy of this message | ||
Sergio Carvalho wrote:
Lukas Smith wrote:Cause you cant write code that can handle both exceptions and PEAR_Error and therefore any code that is supposed to work with both PHP4 _and_ PHP5 needs to use PEAR_Error internally. However this topic is more of a migration topic which doesnt necessarily need to be covered in this RFC. regards, LukasFinally for PHP4/PHP5 packages we may want to ponder a solution where packages optionally return Exceptions to package users. However internally they will use PEAR_Error. I havent really pondered this through but it seems to be fairly annoying to achieve. The best idea I have come up with is that there is a stack which determines what return format to use if exceptions have been enabled. Internal calls will add to the stack telling the class to return PEAR_Errors. Once the stack of internal calls is worked off the package knows to return an Exception as the user requested. The annoying part is that either you leave creating the Exception to raiseError(), thereby screwing with the trace in the exception or you have to duplicate alot of code. Then again we are talking about a cludge here anyways.On a first look, I don't get the advantage of using PEAR_Error internally and presenting Exceptions externally. Can you elaborate?