IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 19034


Ignore:
Timestamp:
Aug 12, 2008, 12:53:34 PM (18 years ago)
Author:
eugene
Message:

adding p_psErrorV and equivalent macro

Location:
trunk/psLib/src/sys
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/sys/psError.c

    r14506 r19034  
    1111 *  @author Eric Van Alst, MHPCC
    1212 *
    13  *  @version $Revision: 1.47 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2007-08-15 20:23:34 $
     13 *  @version $Revision: 1.48 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2008-08-12 22:53:34 $
    1515 *
    1616 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    145145}
    146146
     147psErrorCode 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
    147188psErrorCode p_psError(const char* filename,
    148189                      unsigned int lineno,
     
    153194                      ...)
    154195{
    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 
    165196    va_list ap;
    166197    va_start(ap, format);
    167 
    168     vsnprintf(errMsg, MAX_STRING_LENGTH, format, ap);
    169 
     198    p_psErrorV(filename, lineno, func, code, new, format, ap);
    170199    va_end(ap);
    171 
    172     // Remove a single trailing \n from message -- it interferes with
    173     // psErrorStackPrint
    174     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_TRACE
    183     // Call tracing function with PS_LOG_ERROR level
    184     // p_psTrace() automatically appends the the function name to the facility
    185     // for us
    186     p_psTrace(__FILE__, __LINE__, func, "err", PS_LOG_ERROR, "%s : %s", err->name, err->msg);
    187     #endif
    188 
    189     psFree(err);
    190 
    191200    return code;
    192201}
  • trunk/psLib/src/sys/psError.h

    r14452 r19034  
    1212 *  @author Joshua Hoblitt, University of Hawaii
    1313 *
    14  *  @version $Revision: 1.36 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2007-08-09 01:40:07 $
     14 *  @version $Revision: 1.37 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2008-08-12 22:53:34 $
    1616 *
    1717 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    138138    ...                                ///< any parameters required in format
    139139);
     140psErrorCode psErrorV(
     141    psErrorCode code,                  ///< Error class code
     142    bool new,                          ///< true if error originates at this location
     143    const char* format,                ///< printf-style format of header line
     144    va_list ap                         ///< any parameters required in format
     145);
    140146#else // ifdef DOXYGEN
    141147psErrorCode p_psError(
     
    148154    ...                                ///< any parameters required in format
    149155) PS_ATTR_FORMAT(printf, 6, 7);
     156psErrorCode p_psErrorV(
     157    const char* filename,              ///< file name
     158    unsigned int lineno,               ///< line number in file
     159    const char* func,                  ///< function name
     160    psErrorCode code,                  ///< Error class code
     161    bool new,                          ///< true if error originates at this location
     162    const char* format,                ///< printf-style format of header line
     163    va_list ap                         ///< any parameters required in format
     164  );
    150165#ifndef SWIG
    151 #define psError(code,new,...) \
    152       p_psError(__FILE__,__LINE__,__func__,code,new,__VA_ARGS__)
     166#define psError(code,new,...) p_psError(__FILE__,__LINE__,__func__,code,new,__VA_ARGS__)
     167#define psErrorV(code,new,format,ap) p_psErrorV(__FILE__,__LINE__,__func__,code,new,format,ap)
    153168#endif // ifndef SWIG
    154169#endif // ifdef DOXYGEN
Note: See TracChangeset for help on using the changeset viewer.