Re: Exceptions was Basic DB/MDB Question
| From: | Dan Rossi | Date: | Wed, 23 Mar 2005 00:21:16 +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-18251@lists.php.net to get a copy of this message | ||
I read your concerns about exceptions, so you are not going to get in PHP5 coding at all ?
http://blog.thinkphp.de/archives/14-ReflectionClasshasMethod.html
Personally I wouldnt want to add exception code until the end. I just tried to see what PEAR_ERROR_EXCEPTION mode would do in the setErrorHandling method of pear, it told me to use pear error stack instead, I would then need the library i am using to use errorStack insetad of raiseError right ? Or I set the errorStack stuff on my end and catches the raiseError stuff ?
This ideally means however you wont get a complete view of code while developing and debugging. Personally I dont want to see exception debug code on a finished product, thats the most errornous failings of Java developers, I simply dont want to see exception code on a finished product, turn debugging off and show a user friendly error screen output with a simple message ! So in the end, raiseError or whatever should be standard, using exceptions or not, and then in your one place you select if you want it to use exceptions or not. Personally I have confidence in it, because it is handled at a lower level and shows me detailed output.
However I just tried that PEAR_ERROR_EXCEPTION and it didnt tell me what I needed to know which is found in the getDebugInfo method. PEAR_ERROR_DIE does the same it wont display getDebugInfo only getMessage which is extremely basic and relies on what is set in the API ie MDB2 Error : no such field whereas I also needed the mysql output info of blah blah blah .. Unknown column 'ile_number' , now I hope exceptions can show that too.
I am currently looking at ways for the PEAR_ERROR_CALLBACK to goto a static class which is easy setting it as an array in the options argument ie
PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array('Errors','run');
I would however like to have different static error classes for different things ie for the DB class I can handle errors differently to the LiveUser class which I want to display errors differently. Any ideas would be great, but I feel exceptions is more lower level than handling it all on the PHP code level, but PHP internals is a mystery to me so I cant comment much there.
Daniel