Changeset 19034 for trunk/psLib/src/sys/psError.c
- Timestamp:
- Aug 12, 2008, 12:53:34 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/sys/psError.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/sys/psError.c
r14506 r19034 11 11 * @author Eric Van Alst, MHPCC 12 12 * 13 * @version $Revision: 1.4 7$ $Name: not supported by cvs2svn $14 * @date $Date: 200 7-08-15 20:23:34 $13 * @version $Revision: 1.48 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2008-08-12 22:53:34 $ 15 15 * 16 16 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 145 145 } 146 146 147 psErrorCode p_psErrorV(const char* filename, 148 unsigned int lineno, 149 const char* func, 150 psErrorCode code, 151 bool new, 152 const char* format, 153 va_list ap) 154 { 155 char errMsg[MAX_STRING_LENGTH]; 156 char msgName[MAX_STRING_LENGTH]; 157 158 // if this the origin of a new error reset the error stack 159 if (new) { 160 psErrorClear(); 161 } 162 163 snprintf(msgName, MAX_STRING_LENGTH, "%s (%s:%d)", func, filename, lineno); 164 vsnprintf(errMsg, MAX_STRING_LENGTH, format, ap); 165 166 // Remove a single trailing \n from message -- it interferes with 167 // psErrorStackPrint 168 size_t len = strlen(errMsg); 169 if (len > 0 && errMsg[len - 1] == '\n') { 170 errMsg[len - 1] = '\0'; 171 } 172 173 psErr *err = psErrAlloc(msgName, code, errMsg); 174 psErrorStackPush(err); 175 176 #ifndef PS_NO_TRACE 177 // Call tracing function with PS_LOG_ERROR level 178 // p_psTrace() automatically appends the the function name to the facility 179 // for us 180 p_psTrace(__FILE__, __LINE__, func, "err", PS_LOG_ERROR, "%s : %s", err->name, err->msg); 181 #endif 182 183 psFree(err); 184 185 return code; 186 } 187 147 188 psErrorCode p_psError(const char* filename, 148 189 unsigned int lineno, … … 153 194 ...) 154 195 { 155 char errMsg[MAX_STRING_LENGTH];156 char msgName[MAX_STRING_LENGTH];157 158 // if this the origin of a new error reset the error stack159 if (new) {160 psErrorClear();161 }162 163 snprintf(msgName, MAX_STRING_LENGTH, "%s (%s:%d)", func, filename, lineno);164 165 196 va_list ap; 166 197 va_start(ap, format); 167 168 vsnprintf(errMsg, MAX_STRING_LENGTH, format, ap); 169 198 p_psErrorV(filename, lineno, func, code, new, format, ap); 170 199 va_end(ap); 171 172 // Remove a single trailing \n from message -- it interferes with173 // psErrorStackPrint174 size_t len = strlen(errMsg);175 if (len > 0 && errMsg[len - 1] == '\n') {176 errMsg[len - 1] = '\0';177 }178 179 psErr *err = psErrAlloc(msgName, code, errMsg);180 psErrorStackPush(err);181 182 #ifndef PS_NO_TRACE183 // Call tracing function with PS_LOG_ERROR level184 // p_psTrace() automatically appends the the function name to the facility185 // for us186 p_psTrace(__FILE__, __LINE__, func, "err", PS_LOG_ERROR, "%s : %s", err->name, err->msg);187 #endif188 189 psFree(err);190 191 200 return code; 192 201 }
Note:
See TracChangeset
for help on using the changeset viewer.
