Changeset 3064


Ignore:
Timestamp:
22/01/2012 16:26:38 (4 months ago)
Author:
chris
Message:

Remove unnecessary GetNativeErrorMessage?(), add BOX_LOG_SOCKET_ERROR macro.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • box/trunk/lib/common/Logging.h

    r2895 r3064  
    8282        THROW_EXCEPTION_MESSAGE(exception, subtype, \ 
    8383                BOX_FILE_MESSAGE(filename, message)) 
    84  
    85 inline std::string GetNativeErrorMessage() 
    86 { 
    87 #ifdef WIN32 
    88         return GetErrorMessage(GetLastError()); 
    89 #else 
    90         std::ostringstream _box_log_line; 
    91         _box_log_line << std::strerror(errno) << " (" << errno << ")"; 
    92         return _box_log_line.str(); 
    93 #endif 
    94 } 
    9584 
    9685#ifdef WIN32 
     
    10695        #define BOX_LOG_NATIVE_WARNING(stuff) BOX_LOG_WIN_WARNING(stuff) 
    10796        #define BOX_WIN_ERRNO_MESSAGE(error_number, stuff) \ 
    108                 stuff << ": " << GetErrorMessage(error_number) << " (" << error_number << ")" 
     97                stuff << ": " << GetErrorMessage(error_number) 
    10998        #define THROW_WIN_ERROR_NUMBER(message, error_number, exception, subtype) \ 
    11099                THROW_EXCEPTION_MESSAGE(exception, subtype, \ 
     
    113102                THROW_WIN_ERROR_NUMBER(BOX_FILE_MESSAGE(filename, message), \ 
    114103                        error_number, exception, subtype) 
     104        #define THROW_WIN_FILE_ERROR(message, filename, exception, subtype) \ 
     105                THROW_WIN_FILE_ERRNO(message, filename, GetLastError(), \ 
     106                        exception, subtype) 
    115107#else 
    116108        #define BOX_LOG_NATIVE_ERROR(stuff)   BOX_LOG_SYS_ERROR(stuff) 
     
    118110#endif 
    119111 
    120 #define BOX_LOG_SOCKET_ERROR(_type, _name, _port, stuff) \ 
     112#ifdef WIN32 
     113#       define BOX_LOG_SOCKET_ERROR(_type, _name, _port, stuff) \ 
     114        BOX_LOG_WIN_ERROR_NUMBER(stuff << " (type " << _type << ", name " << \ 
     115                _name << ", port " << _port << ")", WSAGetLastError()) 
     116#else 
     117#       define BOX_LOG_SOCKET_ERROR(_type, _name, _port, stuff) \ 
    121118        BOX_LOG_NATIVE_ERROR(stuff << " (type " << _type << ", name " << \ 
    122119                _name << ", port " << _port << ")") 
     120#endif 
    123121 
    124122#define BOX_FORMAT_HEX32(number) \ 
Note: See TracChangeset for help on using the changeset viewer.