diff options
Diffstat (limited to 'libpqpp/pq-connection.cpp')
-rw-r--r-- | libpqpp/pq-connection.cpp | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/libpqpp/pq-connection.cpp b/libpqpp/pq-connection.cpp index 3ec8991..4ebda84 100644 --- a/libpqpp/pq-connection.cpp +++ b/libpqpp/pq-connection.cpp @@ -31,9 +31,8 @@ PQ::Connection::Connection(const std::string & info) : conn(PQconnectdb(info.c_str())) { if (PQstatus(conn) != CONNECTION_OK) { - ConnectionError ce(conn); - PQfinish(conn); - throw ce; + auto dc = std::unique_ptr<PGconn, decltype(&PQfinish)>(conn, &PQfinish); + throw ConnectionError(dc.get()); } PQsetNoticeProcessor(conn, noNoticeProcessor, NULL); } |