Forum OpenACS Q&A: Re: Obtaining the real DB error

Collapse
Posted by Tom Jackson on

Oracle does provide numbered error messages, but I think postgresql is a little lazy in this respect.

Trying to catch this error in pl is not the right solution, I don't think. The error handling in pl is really practically useless. Actually all it might do is to mask the actual error message from being displayed. At any rate, an error will still result, so I don't see the point.

You could check the db beforehand for the unique constraint error. Or if all other error checking is done, probably the only error that will show up is a unique constraint violation, and that leaves you with just catching the insert statement, checking to make sure this was the cause, and then reporting the result back to the user.