Index: /trunk/psLib/src/dataIO/psDB.c
===================================================================
--- /trunk/psLib/src/dataIO/psDB.c	(revision 4255)
+++ /trunk/psLib/src/dataIO/psDB.c	(revision 4256)
@@ -12,6 +12,6 @@
  *  @author Joshua Hoblitt
  *
- *  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-06-07 02:29:44 $
+ *  @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-06-15 01:01:08 $
  *
  *  Copyright 2005 Joshua Hoblitt, University of Hawaii
@@ -35,5 +35,5 @@
 #include "psError.h"
 #include "psString.h"
-
+#include "psFileUtilsErrors.h"
 
 typedef struct
@@ -99,6 +99,8 @@
     }
 
+    // Connect to host and mySql server with specified database
     if (!mysql_real_connect(mysql, host, user, passwd, dbname, 0, NULL, 0)) {
-        psError(PS_ERR_UNKNOWN, true, "Failed to connect to database.  Error: %s", mysql_error(mysql));
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psDB_FAILED_TO_CONNECT,mysql_error(mysql));
 
         mysql_close(mysql);
@@ -116,15 +118,23 @@
 void psDBCleanup(psDB *dbh)
 {
-    mysql_close(dbh->mysql);
-    dbh->mysql = NULL;
-    psFree(dbh);
-
-    // ASC WARNING NOTE: the psDBSQLToPTypeTableCleanup cleanup routine
-    // needs to be called first because it refers to
-    // psDBGetPTypeToSQLTable ...
-    psDBSQLToPTypeTableCleanup();
-    psDBMySQLToSQLTableCleanup();
-    psDBPTypeToSQLTableCleanup();
-    psDBPTypeToMySQLTableCleanup();
+    // Check if argument dbh is NULL
+    if(dbh == NULL) {
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psDB_INVALID_PSDB);
+    } else {
+
+        // Attempt to close specified database connection
+        mysql_close(dbh->mysql);
+        dbh->mysql = NULL;
+        psFree(dbh);
+
+        // ASC WARNING NOTE: the psDBSQLToPTypeTableCleanup cleanup routine
+        // needs to be called first because it refers to
+        // psDBGetPTypeToSQLTable ...
+        psDBSQLToPTypeTableCleanup();
+        psDBMySQLToSQLTableCleanup();
+        psDBPTypeToSQLTableCleanup();
+        psDBPTypeToMySQLTableCleanup();
+    }
 }
 
Index: /trunk/psLib/src/dataIO/psFileUtilsErrors.dat
===================================================================
--- /trunk/psLib/src/dataIO/psFileUtilsErrors.dat	(revision 4255)
+++ /trunk/psLib/src/dataIO/psFileUtilsErrors.dat	(revision 4256)
@@ -57,2 +57,6 @@
 psFits_FITS_Z_SMALL                    Current FITS HDU has %d z-planes, but z-plane %d was specified.
 #
+psDB_INVALID_PSDB                      Invalid psDB has been specified.
+psDB_FAILED_TO_CONNECT                 Failed to connect to database.  Error: %s
+#
+
Index: /trunk/psLib/src/dataIO/psFileUtilsErrors.h
===================================================================
--- /trunk/psLib/src/dataIO/psFileUtilsErrors.h	(revision 4255)
+++ /trunk/psLib/src/dataIO/psFileUtilsErrors.h	(revision 4256)
@@ -7,6 +7,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-06-08 23:40:45 $
+ *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-06-15 01:01:08 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -76,4 +76,6 @@
 #define PS_ERRORTEXT_psFits_IMAGE_UPDATE_TYPE_MISMATCH "Can not update a %s image given a %s image."
 #define PS_ERRORTEXT_psFits_FITS_Z_SMALL "Current FITS HDU has %d z-planes, but z-plane %d was specified."
+#define PS_ERRORTEXT_psDB_INVALID_PSDB "Invalid psDB has been specified."
+#define PS_ERRORTEXT_psDB_FAILED_TO_CONNECT "Failed to connect to database.  Error: %s"
 //~End
 
Index: /trunk/psLib/src/db/psDB.c
===================================================================
--- /trunk/psLib/src/db/psDB.c	(revision 4255)
+++ /trunk/psLib/src/db/psDB.c	(revision 4256)
@@ -12,6 +12,6 @@
  *  @author Joshua Hoblitt
  *
- *  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-06-07 02:29:44 $
+ *  @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-06-15 01:01:08 $
  *
  *  Copyright 2005 Joshua Hoblitt, University of Hawaii
@@ -35,5 +35,5 @@
 #include "psError.h"
 #include "psString.h"
-
+#include "psFileUtilsErrors.h"
 
 typedef struct
@@ -99,6 +99,8 @@
     }
 
+    // Connect to host and mySql server with specified database
     if (!mysql_real_connect(mysql, host, user, passwd, dbname, 0, NULL, 0)) {
-        psError(PS_ERR_UNKNOWN, true, "Failed to connect to database.  Error: %s", mysql_error(mysql));
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psDB_FAILED_TO_CONNECT,mysql_error(mysql));
 
         mysql_close(mysql);
@@ -116,15 +118,23 @@
 void psDBCleanup(psDB *dbh)
 {
-    mysql_close(dbh->mysql);
-    dbh->mysql = NULL;
-    psFree(dbh);
-
-    // ASC WARNING NOTE: the psDBSQLToPTypeTableCleanup cleanup routine
-    // needs to be called first because it refers to
-    // psDBGetPTypeToSQLTable ...
-    psDBSQLToPTypeTableCleanup();
-    psDBMySQLToSQLTableCleanup();
-    psDBPTypeToSQLTableCleanup();
-    psDBPTypeToMySQLTableCleanup();
+    // Check if argument dbh is NULL
+    if(dbh == NULL) {
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psDB_INVALID_PSDB);
+    } else {
+
+        // Attempt to close specified database connection
+        mysql_close(dbh->mysql);
+        dbh->mysql = NULL;
+        psFree(dbh);
+
+        // ASC WARNING NOTE: the psDBSQLToPTypeTableCleanup cleanup routine
+        // needs to be called first because it refers to
+        // psDBGetPTypeToSQLTable ...
+        psDBSQLToPTypeTableCleanup();
+        psDBMySQLToSQLTableCleanup();
+        psDBPTypeToSQLTableCleanup();
+        psDBPTypeToMySQLTableCleanup();
+    }
 }
 
