From 37140ef351bde540b17a8dcc0e09073281753ff4 Mon Sep 17 00:00:00 2001 From: Paul Ramsey Date: Fri, 14 Jun 2013 13:39:46 -0700 Subject: [PATCH] Throw error messages using session --- include/pdal/drivers/pgpointcloud/common.hpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/include/pdal/drivers/pgpointcloud/common.hpp b/include/pdal/drivers/pgpointcloud/common.hpp index d712dcc8ee..432a893dd0 100644 --- a/include/pdal/drivers/pgpointcloud/common.hpp +++ b/include/pdal/drivers/pgpointcloud/common.hpp @@ -101,7 +101,7 @@ inline void pg_execute(PGconn* session, std::string const& sql) PGresult *result = PQexec(session, sql.c_str()); if ( (!result) || (PQresultStatus(result) != PGRES_COMMAND_OK) ) { - throw pdal_error(PQresultErrorMessage(result)); + throw pdal_error(PQerrorMessage(session)); } PQclear(result); } @@ -138,10 +138,12 @@ inline char* pg_query_once(PGconn* session, std::string const& sql) inline PGresult* pg_query_result(PGconn* session, std::string const& sql) { PGresult *result = PQexec(session, sql.c_str()); + if ( ! result ) + throw pdal_error(PQerrorMessage(session)); + if ( PQresultStatus(result) != PGRES_TUPLES_OK ) - { throw pdal_error(PQresultErrorMessage(result)); - } + return result; }