Changeset 20752

Show
Ignore:
Timestamp:
09/04/07 08:32:51 (1 year ago)
Author:
patrick
Message:

MF22 r20749: Do not retrieve the error message if the "error" state is

ERROR_SUCCESS.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • juggler/trunk/modules/vapor/vpr/md/WIN32/Util/ErrorImplWin32.cpp

    r19729 r20752  
    4444std::string ErrorImplWin32::getCurrentErrorMsg() 
    4545{ 
    46    char* msg_buffer(NULL); 
     46   std::string err_str; 
     47   const DWORD error_code(GetLastError()); 
    4748 
    48    DWORD error_code = GetLastError(); 
    49    FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, 
    50                  NULL, error_code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), 
    51                  (LPTSTR) &msg_buffer, 0, NULL); 
     49   if ( ERROR_SUCCESS != error_code ) 
     50   { 
     51      char* msg_buffer(NULL); 
    5252 
    53    std::string err_str; 
     53      FormatMessage( 
     54         FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, 
     55         NULL, error_code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), 
     56         (LPTSTR) &msg_buffer, 0, NULL 
     57      ); 
    5458 
    55    if ( NULL != msg_buffer ) 
    56    { 
    57       err_str = msg_buffer; 
    58       LocalFree(msg_buffer); 
     59      if ( NULL != msg_buffer ) 
     60      { 
     61         err_str = msg_buffer; 
     62         LocalFree(msg_buffer); 
     63      } 
    5964   } 
    6065 
  • juggler/trunk/modules/vapor/vpr/md/WIN32/Util/ErrorImplWin32.h

    r19729 r20752  
    5555{ 
    5656public: 
     57   /** 
     58    * Returns the current error message from the OS for a failed operation. 
     59    * If the current error code is \c ERROR_SUCCESS or there is no message for 
     60    * the current error, then an empty string is returned. 
     61    */ 
    5762   static std::string getCurrentErrorMsg(); 
    5863