Re: native error handling in PEAR::DB drivers

From: Date: Mon, 09 Jun 2003 17:12:38 +0000
Subject: Re: native error handling in PEAR::DB drivers
References: 1 2 3  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-17217@lists.php.net to get a copy of this message
On Mon, Jun 09, 2003 at 06:16:19PM +0200, Roman Neuhauser wrote: > > I think the lowest common denominator is going to be the error code, > > and it makes sense that all of the errorNative() calls should return a > > consistent type of error. > > > > Perhaps errorNative() could grow an optional parameter ($verbose?) > > that would indicate that the caller was also interested in the error > > text (if available), as well? > > I've been playing with errorNative() methods, and unfortunately > several PHP extensions expose no (easy, known to me) way of getting > at any native error code, and some parse it out of the native error > message. > > That makes me think the best option is having errorNative() return > an array like the one returned by OCIError(). That's not a bad idea, but it does make calling errorNative() a little more complicated for the caller, and, while you've "standardized" the return value of errorNative(), you haven't really guaranteed that you're going to provide both an error code and an error message. That gives the caller even more stuff to check. Handling errors and exceptions should be as easy as possible for the caller. > This is a bit complicated as I don't know the error message format > of all the databases, or other ways of getting at the codes. As Martin points out, someone surely does. > For example, a user note at > ©£=0 > y8©2@÷Shttp://www.php.net/manual/en/function.mssql-get-last-message.php > states that you can get the code from SELECT @@ERROR. This would > make the mssql driver more compatible with the rest, but would this > be welcome? That looks fine to me. -- Jon Parise (jon@php.net) :: The PHP Project (http://www.php.net/)

« previous php.pear.dev (#17217) next »