Just an update, it was making a mistake, the execution of PQexecute, to execute the query, was wrapped in a function called "PGresult *db_execute(....)" that was returning the PGresult as NULL, i completely forgot this, inside that function the exception was being caught and discarded so by the time i got the PGresult pointer back in the caller it contained nothing so trying to read any error from it at that point was useless.
Just to clarify and for future reference, the proposal to use ereport worked perfectly as proposed by the all members.
thank you very much!!