Please find attached a POC patch, using \errverbose for the command name. Unfortunately, I didn't see a good way to contain the change in psql only and had to change libpq, adding new interface PQresultBuildErrorMessage(). Also, what I don't like very much is that we need to keep track of the last result from last SendQuery() in psql's pset. So in my view this is sort of a dirty hack that works nonetheless.