Re: Exceptions was Basic DB/MDB Question
| From: | Dan Rossi | Date: | Wed, 23 Mar 2005 01:53:52 +0000 |
| Subject: | Re: Exceptions was Basic DB/MDB Question | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-18257@lists.php.net to get a copy of this message | ||
On 23/03/2005, at 12:25 PM, Justin Patrin wrote:
Ok obviously I havent seen it because I am not on that list, have you got a subject i can search on ?Dan, I suggest you check the pear-dev archives for the *extensive* discussion on Exceptions there. I was a big proponent of sticking with returns for a while but I was won over. There's also an RFC which many of us helped to write.
I think you have a fundamental misunderstanding of the different error types here.Understandable because I have yet to use exceptions here.
You can code for error returns or for exceptions, but you can't just up and switch from one to the other.Hmm right ok, how could I be using try/catch on PEAR libraries that use the pear errors then ? I dont think its worth the trouble, only for my own classes and code then.
The paradigms are fundamentally different. As an example, think of Exceptions bubbling up vs. errors returned.Bubbling up as in error stacking which is what ErrorStack is trying to do ?
If you code for returns but instead get bubbling up youre code is going ot behave unpredictably. The same is true for the opposite. If you code for returns and switch to exceptions you're going to end up with a lot of stupid try / catch / throw blocks which essentially do nothing. Exceptions should go straight to the code which will deal with them. errorStack doesn't "use exceptions". It has some options for exceptions, but I wouldn't say it "uses exceptions". It uses whatever error type you tell it to use (Exceptions, PEAR_Errors, arrays, etc).I dont think u read me right, I know that, if I chose to use an exception class for the ErrorStack or just standard, it still doesnt tell me how I could set error classes or Exceptions for different packages, I guess the package name in the ErrrorStack contructor is what I am suppose to do ie MDB2 etc ... So I have to setup a few ErrorStack calls ?