X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fcore%2Fsystemerror.cpp;h=c6fd341cfcec873e59bef36c161c851f33d4338c;hp=8d8844a280d06da5ef81894ed64d036959f21415;hb=HEAD;hpb=20e0f6744200e48c776d11db681ecab2fb2baa35 diff --git a/source/core/systemerror.cpp b/source/core/systemerror.cpp index 8d8844a..c6fd341 100644 --- a/source/core/systemerror.cpp +++ b/source/core/systemerror.cpp @@ -1,10 +1,3 @@ -#ifdef WIN32 -#include -#include -#else -#include -#include -#endif #include #include "systemerror.h" @@ -14,31 +7,12 @@ namespace Msp { system_error::system_error(const string &w, int c): runtime_error(w+": "+get_message(c)), - code_(c) + m_code(c) { } system_error::system_error(const string &w, const string &e): runtime_error(w+": "+e), - code_(numeric_limits::min()) + m_code(numeric_limits::min()) { } -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 -} - } // namespace Msp