Re: My Experience with PHP5 Error Handling (and possible
| From: | Justin Patrin | Date: | Wed, 25 Aug 2004 18:07:28 +0000 |
| Subject: | Re: My Experience with PHP5 Error Handling (and possible | ||
| References: | 1 2 3 4 5 6 7 8 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-32945@lists.php.net to get a copy of this message | ||
On Wed, 25 Aug 2004 10:06:37 +0100, Sergio Carvalho
<sergio.carvalho@portugalmail.com> wrote:
> Lukas Smith wrote:
> >
> > To me the issue really lies with when to use Exceptions and when not to
> > use Exceptions and this is the point where I disagree with the RFC. Not
> > being able to connect to a database seems like a good case for an
> > Exception in my eyes. Getting a contraint violation on a query isnt.
> > Because the query was send and the database send a reply. Where is the
> > exceptional state that warrents forcing me to wrap a try/catch block to
> > handle this "error" .. potentially even multiple catch blocks.
>
> The wording on the RFC was fine tuned to allow both cases. Its a matter
> of properly defining your method. It all depends on the method being
> able to finish what it documents as its objective. If the method is
> executeQuery, then the constraint violation will prevent if from
> executing the query, and it should throw an exception. If the method is
> sendQuery, it will be able to send the query, and return whatever the
> database responded, regardless of the query actually succeeding in
> databaseland.
>
I completely agree with this assessment. In general, any database
error should be an exception as it stops the query from happening. A
new method (sendQuery) could be made to ignore them or make them
warnings.
--
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder
paperCrane --Justin Patrin--