Error Handling and Debugging Utility

This chapter describes APIs of the utility for error handling and debugging processing.

1. PFM_ERR

Records error information in a log file of the server.

  • Prototype

    void PFM_ERR(char *format, …);
  • Parameters

    Parameter Description

    *format

    Output format.

    Whether there is an input or not (optional).

  • Example

    PFM_ERR("ERROR MESSAGE=%s", pfmStrGetErrorMsg());

2. PFM_DBG

Records debugging information in a log file of the server.

  • Prototype

    void PFM_DBG(char *format, …);
  • Parameters

    Parameter Description

    *format

    Output format.

    Whether there is an input or not (optional).

  • Example

    Long a = 123;
    PFM_DBG("a=%ld", a);

3. PFM_TRY

Records trace log for a function before and after the function is called. If an error occurs during the function call, it goes to the PFM_CATCH label.

  • Prototype

    void PFM_TRY(rc);
  • Parameters

    Parameter Description

    rc

    Function name to trace.

  • Example

    char   str[]  =  "2315";
    long   num, rc;
    PFM_TRY( pfmStrToLong(&num, str) );
    
    return RC_NRM;
    
    PFM_CATCH:
    PFM_ERR("Error!!");
    return rc;

4. PFM_TRYNJ

Records trace log for a function before and after the function is called. Unlike PFM_TRY, if an error occurs during the function call, it does not go to the PFM_CATCH label.

  • Prototype

    void PFM_TRYNJ(rc);
  • Parameters

    Parameter Description

    rc

    Function name to trace.

  • Example

    char   str[]  =  "2315";
    long   num, rc;
    
    PFM_TRYNJ( pfmStrToLong(&num, str) );
    If ( rc != RC_NRM )
    {
    PFM_ERR("Error!!");
        return rc;
    }
    
    return RC_NRM;

5. PFM_HEXDUMP

Records Hexadecimal code log about buffer data.

  • Prototype

    Void PFM_HEXDUMP(void *in_data, long in_len);
  • Parameters

    Parameter Description

    *in_data

    Pointer to the buffer.

    in_len

    Buffer size.

  • Example

    char buf[128] = "abcdefg";
    long len = strlen(buf);
    
    PFM_HEXDUMP( buf, len );

6. pfmUtilGetErrorMsg

Returns an error message when a Date, Number, or String utility error occurs.

  • Prototype

    char * pfmUtilGetErrorMsg(void);
  • Example

    rc = pfmStrCpyRPadSpace(dest, src, sizeof(dest));
    if(rc != RC_NRM) {
       PFM_ERR("%s", pfmUtilGetErrorMsg());
       return RC_ERR;
    }