NamedEvent_WIN32 be more verbose on SystemException with GetLastError()

This commit is contained in:
Markus Kolb 2014-07-11 15:03:06 +02:00
parent 37691144df
commit c39ad4da65
2 changed files with 12 additions and 2 deletions

View File

@ -15,7 +15,9 @@
#include "Poco/NamedEvent_WIN32.h" #include "Poco/NamedEvent_WIN32.h"
#include "Poco/Error.h"
#include "Poco/Exception.h" #include "Poco/Exception.h"
#include "Poco/Format.h"
namespace Poco { namespace Poco {
@ -26,7 +28,10 @@ NamedEventImpl::NamedEventImpl(const std::string& name):
{ {
_event = CreateEventA(NULL, FALSE, FALSE, _name.c_str()); _event = CreateEventA(NULL, FALSE, FALSE, _name.c_str());
if (!_event) if (!_event)
throw SystemException("cannot create named event", _name); {
DWORD dwRetVal = GetLastError();
throw SystemException(format("cannot create named event %s [Error %d: %s]", _name, (int)dwRetVal, Error::getMessage(dwRetVal)));
}
} }

View File

@ -15,7 +15,9 @@
#include "Poco/NamedEvent_WIN32U.h" #include "Poco/NamedEvent_WIN32U.h"
#include "Poco/Error.h"
#include "Poco/Exception.h" #include "Poco/Exception.h"
#include "Poco/Format.h"
#include "Poco/UnicodeConverter.h" #include "Poco/UnicodeConverter.h"
@ -28,7 +30,10 @@ NamedEventImpl::NamedEventImpl(const std::string& name):
UnicodeConverter::toUTF16(_name, _uname); UnicodeConverter::toUTF16(_name, _uname);
_event = CreateEventW(NULL, FALSE, FALSE, _uname.c_str()); _event = CreateEventW(NULL, FALSE, FALSE, _uname.c_str());
if (!_event) if (!_event)
throw SystemException("cannot create named event", _name); {
DWORD dwRetVal = GetLastError();
throw SystemException(format("cannot create named event %s [Error %d: %s]", _name, (int)dwRetVal, Error::getMessage(dwRetVal)));
}
} }