Changeset 1905 for trunk/psLib/src/sys/psErrorCodes.c
- Timestamp:
- Sep 27, 2004, 10:38:02 AM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/sys/psErrorCodes.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
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
Note:
See TracChangeset
for help on using the changeset viewer.
