diff --git a/plugins/input/postgis/connection.hpp b/plugins/input/postgis/connection.hpp index 94086fb727..6f0a6add17 100644 --- a/plugins/input/postgis/connection.hpp +++ b/plugins/input/postgis/connection.hpp @@ -53,7 +53,7 @@ class Connection { std::ostringstream s; s << "Postgis Plugin: "; - if (conn_ ) + if (conn_) { std::string msg = PQerrorMessage(conn_); if (! msg.empty()) @@ -64,14 +64,13 @@ class Connection { s << "unable to connect to postgres server"; } + PQfinish(conn_); } else { s << "unable to connect to postgres server"; } s << "\n" << connection_str; - - PQfinish(conn_); throw mapnik::datasource_exception(s.str()); } }