Catch an exception if we can not setup a database transaction.
[gnucomo.git] / src / lib / database.cpp
index 82c4332..fb497ec 100644 (file)
@@ -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
 **
 
 /*****************************
    $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 <AXE/date.h>
 
@@ -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++;
    }
 }