Index: trunk/psLib/src/dataIO/psDB.c
===================================================================
--- trunk/psLib/src/dataIO/psDB.c	(revision 4128)
+++ 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();
+    }
 }
 
