Re: Error handling strategies (db related)
| From: | Peter Lind | Date: | Tue, 27 Apr 2010 08:46:36 +0000 |
| Subject: | Re: Error handling strategies (db related) | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-304641@lists.php.net to get a copy of this message | ||
On 27 April 2010 10:42, Gary . <php-general@garydjones.name> 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. If it's an admin with dev knowledge
(i.e. you) then consider handing out the returned error as well.
Rule of thumb: aim to inform the user without confusing. There's
nothing worse than "This didn't work, sorry" - why didn't it work??
Was it my fault? Can I get it to work somehow?
Regards
Peter
--
<hype>
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
Flickr: http://www.flickr.com/photos/fake51
BeWelcome: Fake51
Couchsurfing: Fake51
</hype>