Re: Error handling strategies (db related)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Apr 27, 2010 at 10:46 AM, Peter Lind wrote:
> On 27 April 2010 10:42, Gary . wrote:
>> How do you guys handle errors during, say, db insertions.
>>
>> Let's say you have an ongoing transaction which fails on the n-th
>> insert. Ok, you roll back the transaction, no problem. How do you then
>> inform the user? Just using the text from pg_result_error  or
>> something?
>>
>
> If it's a normal user, give them some info about what went wrong but
> not the specific error returned.

Yeah. I know :( Originally I couldn't find a "nice" way of translating
between db errors and "user" errors. The only interface to the db
errors that I could find was the error messages returned from
pg_last_error. Yes, I could have used an array translating between the
the strings returned by pg_last_error or whatever, but *gag* it would
not only have made the code look horrible but would also have been
susceptible to changes in the error messages returned by the db
interface. In the end I changed tack slightly and used pg_send_* and
pg_result_error_field to get a short code I could use as a reference
into an array.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux