]> git.tdb.fi Git - libs/core.git/blobdiff - source/core/systemerror.cpp
Add move semantics to Variant
[libs/core.git] / source / core / systemerror.cpp
index 6d1d876c1f3e00fb94886a1612454af7443bf01a..c6fd341cfcec873e59bef36c161c851f33d4338c 100644 (file)
@@ -1,10 +1,4 @@
-#ifdef WIN32
-#include <windows.h>
-#include <msp/strings/lexicalcast.h>
-#else
-#include <cerrno>
-#include <cstring>
-#endif
+#include <limits>
 #include "systemerror.h"
 
 using namespace std;
@@ -13,26 +7,12 @@ namespace Msp {
 
 system_error::system_error(const string &w, int c):
        runtime_error(w+": "+get_message(c)),
-       code_(c)
+       m_code(c)
 { }
 
-string system_error::get_message(int c)
-{
-#ifdef WIN32
-       if(c==-1)
-               c = GetLastError();
-
-       char msg[1024];
-       if(FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, 0, c, 0, msg, sizeof(msg), 0))
-               return msg;
-       else
-               return lexical_cast(c, Fmt().hex());
-#else
-       if(c==-1)
-               c = errno;
-
-       return strerror(c);
-#endif
-}
+system_error::system_error(const string &w, const string &e):
+       runtime_error(w+": "+e),
+       m_code(numeric_limits<int>::min())
+{ }
 
 } // namespace Msp