Index: /trunk/psLib/src/sys/psError.c
===================================================================
--- /trunk/psLib/src/sys/psError.c	(revision 1867)
+++ /trunk/psLib/src/sys/psError.c	(revision 1868)
@@ -10,6 +10,6 @@
  *  @author Eric Van Alst, MHPCC
  *   
- *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-09-14 23:48:25 $
+ *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-09-23 22:02:06 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -95,8 +95,16 @@
 }
 
-void psErrorMsg(const char *name, psErrorCode code, bool new, const char* fmt, ...)
+psErrorCode psErrorMsg(const char *name, psErrorCode code, bool new, const char* fmt, ...)
 {
     char errMsg[1024];
     psErr* err;
+    char* msgName;
+
+    // Check for null pointer and if found set to empty string;
+    if ( name == NULL ) {
+        msgName = "";
+    } else {
+        msgName = (char*)name;
+    }
 
     va_list argPtr;             // variable list arguement pointer
@@ -110,9 +118,9 @@
 
     vsnprintf(errMsg,1024,fmt,argPtr);
-    err = psErrAlloc(name,code,errMsg);
+    err = psErrAlloc(msgName,code,errMsg);
     pushErrorStack(err);
 
     // Call logging function with PS_LOG_ERROR level
-    psLogMsg(name, PS_LOG_ERROR, errMsg);
+    psLogMsg(msgName, PS_LOG_ERROR, errMsg);
 
     // Clean up stack after variable argument has been used
@@ -120,4 +128,6 @@
 
     psFree(err);
+
+    return code;
 }
 
@@ -128,9 +138,15 @@
     pthread_mutex_lock(&lockErrorStack);
 
-    which = errorStackSize-1-which;     // the which input is from the end of errorStack
-    if (which < 0 || which >= errorStackSize) {
-        result = psErrAlloc("",PS_ERR_NONE,"");    // no error at the given location
+    // Check for negative reference and if found return PS_ERR_NONE
+    if (which < 0 ) {
+        result = psErrAlloc("", PS_ERR_NONE, "");
     } else {
-        result = psMemIncrRefCounter(errorStack[which]); // a new reference passed back
+
+        which = errorStackSize-1-which;     // the which input is from the end of errorStack
+        if (which < 0 || which >= errorStackSize) {
+            result = psErrAlloc("",PS_ERR_NONE,"");    // no error at the given location
+        } else {
+            result = psMemIncrRefCounter(errorStack[which]); // a new reference passed back
+        }
     }
 
Index: /trunk/psLib/src/sysUtils/psError.c
===================================================================
--- /trunk/psLib/src/sysUtils/psError.c	(revision 1867)
+++ /trunk/psLib/src/sysUtils/psError.c	(revision 1868)
@@ -10,6 +10,6 @@
  *  @author Eric Van Alst, MHPCC
  *   
- *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-09-14 23:48:25 $
+ *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-09-23 22:02:06 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -95,8 +95,16 @@
 }
 
-void psErrorMsg(const char *name, psErrorCode code, bool new, const char* fmt, ...)
+psErrorCode psErrorMsg(const char *name, psErrorCode code, bool new, const char* fmt, ...)
 {
     char errMsg[1024];
     psErr* err;
+    char* msgName;
+
+    // Check for null pointer and if found set to empty string;
+    if ( name == NULL ) {
+        msgName = "";
+    } else {
+        msgName = (char*)name;
+    }
 
     va_list argPtr;             // variable list arguement pointer
@@ -110,9 +118,9 @@
 
     vsnprintf(errMsg,1024,fmt,argPtr);
-    err = psErrAlloc(name,code,errMsg);
+    err = psErrAlloc(msgName,code,errMsg);
     pushErrorStack(err);
 
     // Call logging function with PS_LOG_ERROR level
-    psLogMsg(name, PS_LOG_ERROR, errMsg);
+    psLogMsg(msgName, PS_LOG_ERROR, errMsg);
 
     // Clean up stack after variable argument has been used
@@ -120,4 +128,6 @@
 
     psFree(err);
+
+    return code;
 }
 
@@ -128,9 +138,15 @@
     pthread_mutex_lock(&lockErrorStack);
 
-    which = errorStackSize-1-which;     // the which input is from the end of errorStack
-    if (which < 0 || which >= errorStackSize) {
-        result = psErrAlloc("",PS_ERR_NONE,"");    // no error at the given location
+    // Check for negative reference and if found return PS_ERR_NONE
+    if (which < 0 ) {
+        result = psErrAlloc("", PS_ERR_NONE, "");
     } else {
-        result = psMemIncrRefCounter(errorStack[which]); // a new reference passed back
+
+        which = errorStackSize-1-which;     // the which input is from the end of errorStack
+        if (which < 0 || which >= errorStackSize) {
+            result = psErrAlloc("",PS_ERR_NONE,"");    // no error at the given location
+        } else {
+            result = psMemIncrRefCounter(errorStack[which]); // a new reference passed back
+        }
     }
 
