summaryrefslogtreecommitdiff
path: root/cpp/src/IceUtil/Exception.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/IceUtil/Exception.cpp')
-rw-r--r--cpp/src/IceUtil/Exception.cpp84
1 files changed, 77 insertions, 7 deletions
diff --git a/cpp/src/IceUtil/Exception.cpp b/cpp/src/IceUtil/Exception.cpp
index 3f24f1d0001..0c43d6e09f3 100644
--- a/cpp/src/IceUtil/Exception.cpp
+++ b/cpp/src/IceUtil/Exception.cpp
@@ -31,7 +31,8 @@ IceUtil::Exception::~Exception()
string
IceUtil::Exception::ice_name() const
{
- return "IceUtil::Exception";
+ static const string name("IceUtil::Exception");
+ return name;
}
void
@@ -83,23 +84,92 @@ IceUtil::NullHandleException::NullHandleException(const char* file, int line) :
string
IceUtil::NullHandleException::ice_name() const
{
- return "IceUtil::NullHandleException";
+ static const string name("IceUtil::NullHandleException");
+ return name;
}
+IceUtil::Exception*
+IceUtil::NullHandleException::ice_clone() const
+{
+ return new NullHandleException(*this);
+}
+
+void
+IceUtil::NullHandleException::ice_throw() const
+{
+ throw *this;
+}
+
+IceUtil::SyscallException::SyscallException(const string& error, const char* file, int line) :
+ Exception(file, line),
+ _error(error)
+{
+}
+
string
-IceUtil::NullHandleException::ice_description() const
+IceUtil::SyscallException::ice_name() const
{
- return "operation call on null handle";
+ return "IceUtil::SyscallException";
}
+void
+IceUtil::SyscallException::ice_print(ostream& os) const
+{
+ os << _error << ": ";
+ Exception::ice_print(os);
+}
+
+
IceUtil::Exception*
-IceUtil::NullHandleException::ice_clone() const
+IceUtil::SyscallException::ice_clone() const
{
- return new NullHandleException(*this);
+ return new SyscallException(*this);
}
void
-IceUtil::NullHandleException::ice_throw() const
+IceUtil::SyscallException::ice_throw() const
+{
+ throw *this;
+}
+
+#ifdef WIN32
+string
+IceUtil::SyscallException::errorToString(DWORD error)
+{
+ LPVOID lpMsgBuf;
+ FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ error,
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
+ (LPTSTR)&lpMsgBuf,
+ 0,
+ NULL);
+ string result = (LPCTSTR)lpMsgBuf;
+ LocalFree( lpMsgBuf );
+ return result;
+}
+#endif
+
+IceUtil::LockedException::LockedException(const char* file, int line) :
+ Exception(file, line)
+{
+}
+
+string
+IceUtil::LockedException::ice_name() const
+{
+ static const string name = "IceUtil::LockedException";
+ return name;
+}
+
+IceUtil::Exception*
+IceUtil::LockedException::ice_clone() const
+{
+ return new LockedException(*this);
+}
+
+void
+IceUtil::LockedException::ice_throw() const
{
throw *this;
}