Re: MySQL class. Thoughts?
| From: | Nathan Rixham | Date: | Wed, 21 Jan 2009 21:19:05 +0000 |
| Subject: | Re: MySQL class. Thoughts? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-286957@lists.php.net to get a copy of this message | ||
ceo@l-i-e.com wrote:
i use them often, basically if a boolean false won't do its a case of throwing an exception. let's say you have: calls_fifty_methods($page_load_of_variables); wrap that bit in a try catch and you get try { calls_fifty_methods($page_load_of_variables); } catch ( DatabaseException $e) { // handle that error } catch ( FileNotFoundException $e) { // handle } catch ( VerySpecificException) { // handle } catch ( Exception $e ) { // didn't expect this, notify devs, error log it and do X Y Z } try firing back error codes or something from 50 methods down and you have a real can go wrong easily series of returning error codes and processing the same anyways; or you could take the echo some html approach from the function - which is wrong on so many levels or..there is an art to using them, they compliment 'traditional' error handling, and I agree they can hinder if used badly.I don't think I've ever seen Exceptions used well... Invariably, I end up having to write a wrapper function around every function implemented and catch all the Exceptions. Otherwise, my code is littered with try/catch blocks for every little thing the other guy was too lazy to figure out how to handle gracefully. ymmv