summaryrefslogtreecommitdiff
path: root/lib/common/Logging.h
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2015-04-06 19:41:22 +0000
committerChris Wilson <chris+github@qwirx.com>2015-04-06 19:41:22 +0000
commit3cf9311eba9e6b8374b877eea385031936d187ba (patch)
tree72b4a602099c2093be35bfb40366fa052fbe3ea6 /lib/common/Logging.h
parentaeba7f1751b853d0ff85bf77abfc3d2179640d85 (diff)
Improve error logging in win32 emu library.
Consistently capture the last Windows error code in the global variable winerrno. Add logging macros that report the Windows error message for this error code.
Diffstat (limited to 'lib/common/Logging.h')
-rw-r--r--lib/common/Logging.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/common/Logging.h b/lib/common/Logging.h
index 24a773db..26199701 100644
--- a/lib/common/Logging.h
+++ b/lib/common/Logging.h
@@ -98,6 +98,8 @@
#define BOX_WIN_ERRNO_MESSAGE(error_number, stuff) \
stuff << ": " << GetErrorMessage(error_number) << \
" (" << error_number << ")"
+ #define BOX_NATIVE_ERRNO_MESSAGE(error_number, stuff) \
+ BOX_WIN_ERRNO_MESSAGE(error_number, stuff)
#define BOX_LOG_WIN_ERROR(stuff) \
BOX_ERROR(BOX_WIN_ERRNO_MESSAGE(GetLastError(), stuff))
#define BOX_LOG_WIN_WARNING(stuff) \
@@ -117,11 +119,25 @@
#define THROW_WIN_FILE_ERROR(message, filename, exception, subtype) \
THROW_WIN_FILE_ERRNO(message, filename, GetLastError(), \
exception, subtype)
+ #define EMU_ERRNO winerrno
+ #define THROW_EMU_ERROR(message, exception, subtype) \
+ THROW_EXCEPTION_MESSAGE(exception, subtype, \
+ BOX_NATIVE_ERRNO_MESSAGE(EMU_ERRNO, message))
#else
+ #define BOX_NATIVE_ERRNO_MESSAGE(error_number, stuff) \
+ BOX_SYS_ERRNO_MESSAGE(error_number, stuff)
#define BOX_LOG_NATIVE_ERROR(stuff) BOX_LOG_SYS_ERROR(stuff)
#define BOX_LOG_NATIVE_WARNING(stuff) BOX_LOG_SYS_WARNING(stuff)
+ #define EMU_ERRNO errno
+ #define THROW_EMU_ERROR(message, exception, subtype) \
+ THROW_EXCEPTION_MESSAGE(exception, subtype, \
+ BOX_SYS_ERRNO_MESSAGE(EMU_ERRNO, message))
#endif
+#define THROW_EMU_FILE_ERROR(message, filename, exception, subtype) \
+ THROW_EMU_ERROR(BOX_FILE_MESSAGE(filename, message), \
+ exception, subtype)
+
#ifdef WIN32
# define BOX_LOG_SOCKET_ERROR(_type, _name, _port, stuff) \
BOX_LOG_WIN_ERROR_NUMBER(stuff << " (type " << _type << ", name " << \