handle any exception raised by PostgreSQL.cursor()