From 9c4b92927d11c947302f4817775cb80d33a113fe Mon Sep 17 00:00:00 2001 From: arjen Date: Mon, 22 Dec 2003 10:28:26 +0000 Subject: [PATCH] Catch an exception if we can not setup a database transaction. --- src/lib/database.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/lib/database.cpp b/src/lib/database.cpp index 82c4332..fb497ec 100644 --- a/src/lib/database.cpp +++ b/src/lib/database.cpp @@ -8,7 +8,7 @@ *********************** ** FILE NAME : database.cpp ** SYSTEM NAME : Gnucomo - Gnu Computer Monitoring -** VERSION NUMBER : $Revision: 1.11 $ +** VERSION NUMBER : $Revision: 1.12 $ ** ** DESCRIPTION : Implementation of the gnucomo database classes ** @@ -26,7 +26,10 @@ /***************************** $Log: database.cpp,v $ - Revision 1.11 2003-12-04 10:40:28 arjen + Revision 1.12 2003-12-22 10:28:26 arjen + Catch an exception if we can not setup a database transaction. + + Revision 1.11 2003/12/04 10:40:28 arjen Fixed name conflict with 'double log(double)' Revision 1.10 2003/12/03 08:23:17 arjen @@ -64,7 +67,7 @@ *****************************/ -static const char *RCSID = "$Id: database.cpp,v 1.11 2003-12-04 10:40:28 arjen Exp $"; +static const char *RCSID = "$Id: database.cpp,v 1.12 2003-12-22 10:28:26 arjen Exp $"; #include @@ -103,9 +106,18 @@ gnucomo_database::gnucomo_database(gnucomo_config *c) } else { - // Create the transaction object + try + { + // Create the transaction object - dbxact = new pqxx::Transaction(*dbconn, "GnuCoMo"); + dbxact = new pqxx::Transaction(*dbconn, "GnuCoMo"); + } + catch (std::exception &e) + { + *Log << "Cannot setup the database transaction: " << e.what() << "\n"; + *Log << "You are probably using incompatible versions of PostgreSQL an libpqxx.\n"; + exit(1); + } gdb_refcount++; } } -- 2.11.0