diff options
author | Benoit Foucher <benoit@zeroc.com> | 2008-01-23 11:31:53 +0100 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2008-01-23 11:31:53 +0100 |
commit | c7fb26230801e62f3e690a8948d37c33517c4c13 (patch) | |
tree | f17689f60e13fbbd20d12473272a6f0652f39a78 /cpp/src/Ice/StringConverter.cpp | |
parent | removing EventHandler in C# (diff) | |
download | ice-c7fb26230801e62f3e690a8948d37c33517c4c13.tar.bz2 ice-c7fb26230801e62f3e690a8948d37c33517c4c13.tar.xz ice-c7fb26230801e62f3e690a8948d37c33517c4c13.zip |
- Added IceUtil::SyscallException and cleaned up few IceUtil exceptions
- Added errorToString() and lastErrorToString() functions to IceUtil/StringUtil.h
- Replaced multiple implementations of errorToString methods with the IceUtil one.
- Fixed bug 2641.
Diffstat (limited to 'cpp/src/Ice/StringConverter.cpp')
-rwxr-xr-x | cpp/src/Ice/StringConverter.cpp | 42 |
1 files changed, 3 insertions, 39 deletions
diff --git a/cpp/src/Ice/StringConverter.cpp b/cpp/src/Ice/StringConverter.cpp index ec88ab47188..a89fa716494 100755 --- a/cpp/src/Ice/StringConverter.cpp +++ b/cpp/src/Ice/StringConverter.cpp @@ -9,6 +9,7 @@ #include <Ice/StringConverter.h> #include <IceUtil/IceUtil.h> +#include <IceUtil/StringUtil.h> #include <IceUtil/ScopedArray.h> #include <Ice/LocalException.h> @@ -16,43 +17,6 @@ using namespace IceUtil; using namespace IceUtilInternal; using namespace std; - -#ifdef _WIN32 -namespace -{ -// -// Helper function -// - -string getMessageForLastError() -{ - LPVOID lpMsgBuf = 0; - DWORD ok = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - GetLastError(), - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language - (LPTSTR)&lpMsgBuf, - 0, - NULL); - - string msg; - if(ok) - { - msg = (LPCTSTR)lpMsgBuf; - LocalFree(lpMsgBuf); - } - else - { - msg = "Unknown Windows error"; - } - return msg; -} -} -#endif - - namespace Ice { @@ -162,7 +126,7 @@ WindowsStringConverter::toUTF8(const char* sourceStart, if(writtenWchar == 0) { - throw StringConversionException(__FILE__, __LINE__, getMessageForLastError()); + throw StringConversionException(__FILE__, __LINE__, IceUtilInternal::lastErrorToString()); } // @@ -203,7 +167,7 @@ WindowsStringConverter::fromUTF8(const Byte* sourceStart, const Byte* sourceEnd, if(writtenChar == 0) { - throw StringConversionException(__FILE__, __LINE__, getMessageForLastError()); + throw StringConversionException(__FILE__, __LINE__, IceUtilInternal::lastErrorToString()); } target.assign(buffer.get(), writtenChar); |