"Thomas Hallgren" <thhal@mailblocks.com> writes:
> My question is, at the point of /* Handle error here */, how do I get hold
> of the error information?
You don't. The above coding technique is entirely unsafe anyway,
because it relies on the assumption that the system is still in a good
state to continue the transaction, which is in general not true.
If we had nested-transaction support you could arrange for an inner
transaction around the thing you want to retry; but we don't, and this
problem of cleaning up after an error is one of the biggest reasons
why not.
regards, tom lane