diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-12-29 02:42:43 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-12-29 06:00:07 +0000 |
commit | da82e9c8f09f3e471044f8b52ede478ac4d5bc04 (patch) | |
tree | eb8c79922a088398ad2e155dec0d6e831a1378ba /libpqpp/pq-connection.cpp | |
parent | Remove rebind (diff) | |
download | libdbpp-postgresql-da82e9c8f09f3e471044f8b52ede478ac4d5bc04.tar.bz2 libdbpp-postgresql-da82e9c8f09f3e471044f8b52ede478ac4d5bc04.tar.xz libdbpp-postgresql-da82e9c8f09f3e471044f8b52ede478ac4d5bc04.zip |
Reshuffle and add new exceptions
Diffstat (limited to 'libpqpp/pq-connection.cpp')
-rw-r--r-- | libpqpp/pq-connection.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
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); } } |