From 83722ef5a1c46ee3e9a15d9c16daf227f06e56cb Mon Sep 17 00:00:00 2001 From: deva Date: Fri, 7 Aug 2009 12:59:53 +0000 Subject: Catch exceptions from new connection. --- server/src/pracrodaopgsql.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'server/src') diff --git a/server/src/pracrodaopgsql.cc b/server/src/pracrodaopgsql.cc index c1ec9b1..d1ba517 100644 --- a/server/src/pracrodaopgsql.cc +++ b/server/src/pracrodaopgsql.cc @@ -54,7 +54,13 @@ PracroDAOPgsql::PracroDAOPgsql(std::string _host, std::string _port, std::string if(user.size()) cs += " user=" + user; if(passwd.size()) cs += " password=" + passwd; cs += " dbname=" + (dbname.size() ? dbname : "pracro"); - conn = new pqxx::connection(cs); + try { + conn = new pqxx::connection(cs); + } catch(std::exception &e) { + PRACRO_ERR_LOG(db, "Postgresql init failed: %s\n", e.what()); + conn = NULL; + } + PRACRO_DEBUG(db, "Pgsql connection %p (%s)\n", conn, cs.c_str()); } -- cgit v1.2.3