From da82e9c8f09f3e471044f8b52ede478ac4d5bc04 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 29 Dec 2015 02:42:43 +0000 Subject: Reshuffle and add new exceptions --- libpqpp/pq-connection.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'libpqpp/pq-connection.cpp') diff --git a/libpqpp/pq-connection.cpp b/libpqpp/pq-connection.cpp index 74fce9e..3de0071 100644 --- a/libpqpp/pq-connection.cpp +++ b/libpqpp/pq-connection.cpp @@ -20,6 +20,11 @@ noNoticeProcessor(void *, const char *) { } +PQ::ConnectionError::ConnectionError(const PGconn * conn) : + PQ::Error(conn) +{ +} + PQ::Connection::Connection(const std::string & info) : conn(PQconnectdb(info.c_str())), txDepth(0), @@ -44,7 +49,7 @@ PQ::Connection::finish() const { if (txDepth != 0) { rollbackTx(); - throw Error("Transaction still open"); + throw DB::TransactionStillOpen(); } } @@ -145,7 +150,7 @@ PQ::Connection::checkResult(PGresult * res, int expected, int alt) const { if (!checkResultInt(res, expected, alt)) { PQclear(res); - throw Error(PQerrorMessage(conn)); + throw Error(conn); } return res; } @@ -155,7 +160,7 @@ PQ::Connection::checkResultFree(PGresult * res, int expected, int alt) const { if (!checkResultInt(res, expected, alt)) { PQclear(res); - throw Error(PQerrorMessage(conn)); + throw Error(conn); } PQclear(res); } @@ -180,7 +185,7 @@ PQ::Connection::endBulkUpload(const char * msg) const checkResultFree(PQgetResult(conn), PGRES_COMMAND_OK); return; default:// -1 is error - throw Error(PQerrorMessage(conn)); + throw Error(conn); } } @@ -194,7 +199,7 @@ PQ::Connection::bulkUploadData(const char * data, size_t len) const case 1:// success return len; default:// -1 is error - throw Error(PQerrorMessage(conn)); + throw Error(conn); } } -- cgit v1.2.3