On 27 April 2010 10:42, Gary . <php-gene...@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? > > Developers are usually lazy about error reporting because it's much easier to just return the error code. Some parsing is very useful to the user, since overtly technical information is just confusing.
The error should never be something that the user himself can avoid (since you're supposed to have error checking and handling before the user submits), so your error should make this clear to him. It helps to let him know that the developer has been notified and that he can try again later. Michiel