Changeset 1905
- Timestamp:
- Sep 27, 2004, 10:38:02 AM (22 years ago)
- Location:
- trunk/psLib/src
- Files:
-
- 8 edited
-
sys/psError.c (modified) (2 diffs)
-
sys/psErrorCodes.c (modified) (5 diffs)
-
sys/psErrorCodes.h (modified) (2 diffs)
-
sysUtils/psError.c (modified) (2 diffs)
-
sysUtils/psErrorCodes.c (modified) (5 diffs)
-
sysUtils/psErrorCodes.h (modified) (2 diffs)
-
sysUtils/psSysUtilsErrors.dat (modified) (1 diff)
-
sysUtils/psSysUtilsErrors.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/sys/psError.c
r1881 r1905 10 10 * @author Eric Van Alst, MHPCC 11 11 * 12 * @version $Revision: 1.1 6$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-09-2 4 21:59:29$12 * @version $Revision: 1.17 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-09-27 20:38:02 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 28 28 static unsigned int errorStackSize = 0; 29 29 pthread_mutex_t lockErrorStack = PTHREAD_MUTEX_INITIALIZER; 30 31 30 32 31 static void pushErrorStack(psErr* err); -
trunk/psLib/src/sys/psErrorCodes.c
r1873 r1905 7 7 * @author Robert DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1. 8$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-09-2 4 01:09:18$9 * @version $Revision: 1.9 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-09-27 20:38:02 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 13 13 */ 14 14 15 #include "psError.h" 15 16 #include "psErrorCodes.h" 16 17 #include "psList.h" 17 18 #include "psMemory.h" 19 20 #include "psSysUtilsErrors.h" 18 21 19 22 /* N.B., lines between '//~Start' and '//~End' are automatic generated from … … 28 31 */ 29 32 30 static psErrorDescription errorDescriptions[] = {33 static psErrorDescription staticErrorCodes[] = { 31 34 {PS_ERR_NONE,"not an error"}, 32 35 {PS_ERR_BASE,"base error"}, … … 46 49 }; 47 50 48 static psList* errorCodes = NULL;49 static psErrorDescription* getErrorDescription(psErrorCode code);51 static psList* dynamicErrorCodes = NULL; 52 static const psErrorDescription* getErrorDescription(psErrorCode code); 50 53 51 54 52 static psErrorDescription* getErrorDescription(psErrorCode code)55 static const psErrorDescription* getErrorDescription(psErrorCode code) 53 56 { 54 57 // first, search the static error codes 55 58 56 59 int n = 0; 57 while( errorDescriptions[n].code != PS_ERR_N_ERR_CLASSES &&58 errorDescriptions[n].code != code) {60 while(staticErrorCodes[n].code != PS_ERR_N_ERR_CLASSES && 61 staticErrorCodes[n].code != code) { 59 62 n++; 60 63 } 61 64 62 if ( errorDescriptions[n].code == code) {63 return & errorDescriptions[n];65 if (staticErrorCodes[n].code == code) { 66 return &staticErrorCodes[n]; 64 67 } else { 65 68 psErrorDescription* desc; 66 69 // make sure there is a list to search 67 if ( errorCodes == NULL) {70 if (dynamicErrorCodes == NULL) { 68 71 return NULL; 69 72 } 70 73 71 74 // search dynamic list of error descriptions before giving up. 72 desc = (psErrorDescription*)psListGet(errorCodes,PS_LIST_HEAD); 73 while (desc != NULL && desc->code != code) { 74 desc = (psErrorDescription*)psListGetNext(errorCodes); 75 } 76 77 if (desc != NULL && desc->code == code) { 78 return psMemIncrRefCounter(desc); 75 desc = (psErrorDescription*)psListGet(dynamicErrorCodes,PS_LIST_HEAD); 76 while (desc != NULL) { 77 desc = (psErrorDescription*)psListGetNext(dynamicErrorCodes); 78 if (desc != NULL && desc->code == code) { 79 return desc; 80 } 79 81 } 80 82 } … … 89 91 } 90 92 91 psErrorDescription* desc = getErrorDescription(code);93 const psErrorDescription* desc = getErrorDescription(code); 92 94 93 95 if (desc == NULL) { … … 98 100 } 99 101 102 void psErrorRegister(const psErrorDescription* errors, 103 int nerror) 104 { 105 if (nerror < 1) { 106 return; 107 } 108 109 if (errors == NULL) { 110 psErrorMsg(PS_ERRORNAME_DOMAIN "psErrorRegister", 111 PS_ERR_BAD_PARAMETER_NULL, true, 112 PS_ERRORTEXT_psErrorCode_NULL_ERRORDESCRIPTION); 113 return; 114 } 115 116 for (int i=0;i<nerror;i++) { 117 if (! psListAdd(dynamicErrorCodes, 118 PS_LIST_HEAD, 119 (void*)&errors[i]) ) { 120 121 psErrorMsg(PS_ERRORNAME_DOMAIN "psErrorRegister", 122 PS_ERR_UNKNOWN, false, 123 PS_ERRORTEXT_psErrorCode_ERRORCODE_REGISTER_FAILED, 124 i); 125 } 126 } 127 } 128 -
trunk/psLib/src/sys/psErrorCodes.h
r1818 r1905 7 7 * @author Robert DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1. 9$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-09- 16 18:51:32 $9 * @version $Revision: 1.10 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-09-27 20:38:02 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 75 75 ); 76 76 77 /** Register an error code 78 * 79 * Any project needed to use psLib must define the necessary error codes and 80 * associated message strings. This function registers an array of error 81 * codes with the error handling subsystem. 82 * 83 */ 84 void psErrorRegister( 85 const psErrorDescription* errors, ///< Array of error codes to register 86 int nerror ///< number of errors in input array 87 ); 88 77 89 /// @} 78 90 -
trunk/psLib/src/sysUtils/psError.c
r1881 r1905 10 10 * @author Eric Van Alst, MHPCC 11 11 * 12 * @version $Revision: 1.1 6$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-09-2 4 21:59:29$12 * @version $Revision: 1.17 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-09-27 20:38:02 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 28 28 static unsigned int errorStackSize = 0; 29 29 pthread_mutex_t lockErrorStack = PTHREAD_MUTEX_INITIALIZER; 30 31 30 32 31 static void pushErrorStack(psErr* err); -
trunk/psLib/src/sysUtils/psErrorCodes.c
r1873 r1905 7 7 * @author Robert DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1. 8$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-09-2 4 01:09:18$9 * @version $Revision: 1.9 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-09-27 20:38:02 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 13 13 */ 14 14 15 #include "psError.h" 15 16 #include "psErrorCodes.h" 16 17 #include "psList.h" 17 18 #include "psMemory.h" 19 20 #include "psSysUtilsErrors.h" 18 21 19 22 /* N.B., lines between '//~Start' and '//~End' are automatic generated from … … 28 31 */ 29 32 30 static psErrorDescription errorDescriptions[] = {33 static psErrorDescription staticErrorCodes[] = { 31 34 {PS_ERR_NONE,"not an error"}, 32 35 {PS_ERR_BASE,"base error"}, … … 46 49 }; 47 50 48 static psList* errorCodes = NULL;49 static psErrorDescription* getErrorDescription(psErrorCode code);51 static psList* dynamicErrorCodes = NULL; 52 static const psErrorDescription* getErrorDescription(psErrorCode code); 50 53 51 54 52 static psErrorDescription* getErrorDescription(psErrorCode code)55 static const psErrorDescription* getErrorDescription(psErrorCode code) 53 56 { 54 57 // first, search the static error codes 55 58 56 59 int n = 0; 57 while( errorDescriptions[n].code != PS_ERR_N_ERR_CLASSES &&58 errorDescriptions[n].code != code) {60 while(staticErrorCodes[n].code != PS_ERR_N_ERR_CLASSES && 61 staticErrorCodes[n].code != code) { 59 62 n++; 60 63 } 61 64 62 if ( errorDescriptions[n].code == code) {63 return & errorDescriptions[n];65 if (staticErrorCodes[n].code == code) { 66 return &staticErrorCodes[n]; 64 67 } else { 65 68 psErrorDescription* desc; 66 69 // make sure there is a list to search 67 if ( errorCodes == NULL) {70 if (dynamicErrorCodes == NULL) { 68 71 return NULL; 69 72 } 70 73 71 74 // search dynamic list of error descriptions before giving up. 72 desc = (psErrorDescription*)psListGet(errorCodes,PS_LIST_HEAD); 73 while (desc != NULL && desc->code != code) { 74 desc = (psErrorDescription*)psListGetNext(errorCodes); 75 } 76 77 if (desc != NULL && desc->code == code) { 78 return psMemIncrRefCounter(desc); 75 desc = (psErrorDescription*)psListGet(dynamicErrorCodes,PS_LIST_HEAD); 76 while (desc != NULL) { 77 desc = (psErrorDescription*)psListGetNext(dynamicErrorCodes); 78 if (desc != NULL && desc->code == code) { 79 return desc; 80 } 79 81 } 80 82 } … … 89 91 } 90 92 91 psErrorDescription* desc = getErrorDescription(code);93 const psErrorDescription* desc = getErrorDescription(code); 92 94 93 95 if (desc == NULL) { … … 98 100 } 99 101 102 void psErrorRegister(const psErrorDescription* errors, 103 int nerror) 104 { 105 if (nerror < 1) { 106 return; 107 } 108 109 if (errors == NULL) { 110 psErrorMsg(PS_ERRORNAME_DOMAIN "psErrorRegister", 111 PS_ERR_BAD_PARAMETER_NULL, true, 112 PS_ERRORTEXT_psErrorCode_NULL_ERRORDESCRIPTION); 113 return; 114 } 115 116 for (int i=0;i<nerror;i++) { 117 if (! psListAdd(dynamicErrorCodes, 118 PS_LIST_HEAD, 119 (void*)&errors[i]) ) { 120 121 psErrorMsg(PS_ERRORNAME_DOMAIN "psErrorRegister", 122 PS_ERR_UNKNOWN, false, 123 PS_ERRORTEXT_psErrorCode_ERRORCODE_REGISTER_FAILED, 124 i); 125 } 126 } 127 } 128 -
trunk/psLib/src/sysUtils/psErrorCodes.h
r1818 r1905 7 7 * @author Robert DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1. 9$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-09- 16 18:51:32 $9 * @version $Revision: 1.10 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-09-27 20:38:02 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 75 75 ); 76 76 77 /** Register an error code 78 * 79 * Any project needed to use psLib must define the necessary error codes and 80 * associated message strings. This function registers an array of error 81 * codes with the error handling subsystem. 82 * 83 */ 84 void psErrorRegister( 85 const psErrorDescription* errors, ///< Array of error codes to register 86 int nerror ///< number of errors in input array 87 ); 88 77 89 /// @} 78 90 -
trunk/psLib/src/sysUtils/psSysUtilsErrors.dat
r1787 r1905 38 38 psTrace_MALFORMED_COMPONENT_NAME Failed to add '%s' to the root component tree; component must start with '.'. 39 39 psTrace_FAILED_TO_ADD_COMPONENT Failed to set trace level (%d) to '%s'. 40 # 41 # Error Messages from psErrorCodes.c 42 # 43 psErrorCode_NULL_ERRORDESCRIPTION Specified psErrorDescription pointer can not be NULL. 44 psErrorCode_ERRORCODE_REGISTER_FAILED Failed to add input psErrorDescription at array index %d. -
trunk/psLib/src/sysUtils/psSysUtilsErrors.h
r1787 r1905 7 7 * @author Robert DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1. 8$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-09- 11 00:43:54$9 * @version $Revision: 1.9 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-09-27 20:38:02 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 45 45 #define PS_ERRORTEXT_psTrace_ADD_NULL_COMPONENT "Failed to add null component to trace tree." 46 46 #define PS_ERRORTEXT_psTrace_MALFORMED_COMPONENT_NAME "Failed to add '%s' to the root component tree; component must start with '.'." 47 #define PS_ERRORTEXT_psTrace_FAILED_TO_ADD_COMPONENT "Failed to set trace level (%d) to '%s'" 47 #define PS_ERRORTEXT_psTrace_FAILED_TO_ADD_COMPONENT "Failed to set trace level (%d) to '%s'." 48 #define PS_ERRORTEXT_psErrorCode_NULL_ERRORDESCRIPTION "Specified psErrorDescription pointer can not be NULL." 49 #define PS_ERRORTEXT_psErrorCode_ERRORCODE_REGISTER_FAILED "Failed to add input psErrorDescription at array index %d" 48 50 //~End 49 51
Note:
See TracChangeset
for help on using the changeset viewer.
