Changeset 456
- Timestamp:
- Apr 19, 2004, 11:24:19 AM (22 years ago)
- Location:
- trunk/archive/pslib
- Files:
-
- 2 edited
-
include/psError.h (modified) (1 diff)
-
src/Utils/error.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/archive/pslib/include/psError.h
r382 r456 34 34 void psErrorClear(void); ///< Clear the error stack 35 35 36 const char *psErrorCodeString(psErrorCode code); ///< return the string associated with the error code 36 37 void psErrorStackPrint(FILE *fd, const char *fmt, ...); ///< print the errorstack to this file descriptor 37 38 void psVErrorStackPrint(FILE *fd, //< write to this file descriptor -
trunk/archive/pslib/src/Utils/error.c
r386 r456 139 139 140 140 /************************************************************************************************************/ 141 142 static void 143 build_errorStringList(void) 144 { 145 for (int i = 0; i < PS_ERR_N_ERR_CLASSES; i++) { 146 errorStringList[i] = NULL; 147 } 148 149 for (int i = 0; i < PS_ERR_N_ERR_CLASSES; i++) { 150 if (errorStrings[i].descrip == NULL) { 151 break; 152 } 153 154 errorStringList[errorStrings[i].code] = errorStrings[i].descrip; 155 } 156 } 157 158 /************************************************************************************************************/ 159 /* 160 * Return the string associated with an error code 161 */ 162 const char *psErrorCodeString(psErrorCode code) 163 { 164 if (errorStringList[PS_ERR_UNKNOWN] == NULL) { // need to build the errorStringList 165 build_errorStringList(); 166 } 167 168 return (code < PS_ERR_BASE ? strerror(code) : errorStringList[code]); 169 } 170 171 /************************************************************************************************************/ 141 172 /* 142 173 * Print the header then error stack to the provided file descriptor … … 165 196 va_list ap) // arguments for format 166 197 { 167 static int first = 1; 168 169 if (first) { // need to build the errorStringList 170 first = 0; 171 172 for (int i = 0; i < PS_ERR_N_ERR_CLASSES; i++) { 173 errorStringList[i] = NULL; 174 } 175 176 for (int i = 0; i < PS_ERR_N_ERR_CLASSES; i++) { 177 if (errorStrings[i].descrip == NULL) { 178 break; 179 } 180 181 errorStringList[errorStrings[i].code] = errorStrings[i].descrip; 182 } 198 if (errorStringList[PS_ERR_UNKNOWN] == NULL) { // need to build the errorStringList 199 build_errorStringList(); 183 200 } 184 201 … … 208 225 int code = stack[i]->error.code; 209 226 fprintf(fd, "%*s%-*s %-30s %s\n", 210 i, "", 30 - i, stack[i]->error.name, 211 (code < PS_ERR_BASE ? strerror(code) : errorStringList[code]), stack[i]->error.msg); 212 } 213 } 227 i, "", 30 - i, stack[i]->error.name, psErrorCodeString(code), stack[i]->error.msg); 228 } 229 }
Note:
See TracChangeset
for help on using the changeset viewer.
