From 2383d25fffcb2f73b6a42677407a991533b3a7a7 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Tue, 30 Dec 2008 18:30:41 +0000 Subject: Add a function to return a native error message as a string. --- lib/common/Logging.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'lib/common') diff --git a/lib/common/Logging.h b/lib/common/Logging.h index 3d5ea370..40c94a09 100644 --- a/lib/common/Logging.h +++ b/lib/common/Logging.h @@ -10,6 +10,7 @@ #ifndef LOGGING__H #define LOGGING__H +#include #include #include #include @@ -58,6 +59,17 @@ #define BOX_LOG_SYS_FATAL(stuff) \ BOX_FATAL(stuff << ": " << std::strerror(errno) << " (" << errno << ")") +inline std::string GetNativeErrorMessage() +{ +#ifdef WIN32 + return GetErrorMessage(GetLastError()); +#else + std::ostringstream _box_log_line; + _box_log_line << std::strerror(errno) << " (" << errno << ")"; + return _box_log_line.str(); +#endif +} + #ifdef WIN32 #define BOX_LOG_WIN_ERROR(stuff) \ BOX_ERROR(stuff << ": " << GetErrorMessage(GetLastError())) -- cgit v1.2.3