summaryrefslogtreecommitdiff
path: root/lib/common/Logging.h
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2008-12-30 18:30:41 +0000
committerChris Wilson <chris+github@qwirx.com>2008-12-30 18:30:41 +0000
commit2383d25fffcb2f73b6a42677407a991533b3a7a7 (patch)
treec879b8b1878e0b28af8939b2c6d8878c6bab2b46 /lib/common/Logging.h
parentc13f1bfdc3673ba1d1b79284d834e9248c20e8ef (diff)
Add a function to return a native error message as a string.
Diffstat (limited to 'lib/common/Logging.h')
-rw-r--r--lib/common/Logging.h12
1 files changed, 12 insertions, 0 deletions
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 <cerrno>
#include <cstring>
#include <iomanip>
#include <sstream>
@@ -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()))