summaryrefslogtreecommitdiff
path: root/cpp/src/IceUtil/Exception.cpp
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2008-01-23 11:31:53 +0100
committerBenoit Foucher <benoit@zeroc.com>2008-01-23 11:31:53 +0100
commitc7fb26230801e62f3e690a8948d37c33517c4c13 (patch)
treef17689f60e13fbbd20d12473272a6f0652f39a78 /cpp/src/IceUtil/Exception.cpp
parentremoving EventHandler in C# (diff)
downloadice-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/IceUtil/Exception.cpp')
-rw-r--r--cpp/src/IceUtil/Exception.cpp61
1 files changed, 55 insertions, 6 deletions
diff --git a/cpp/src/IceUtil/Exception.cpp b/cpp/src/IceUtil/Exception.cpp
index e893cb08397..cc8e8e0c4aa 100644
--- a/cpp/src/IceUtil/Exception.cpp
+++ b/cpp/src/IceUtil/Exception.cpp
@@ -9,6 +9,7 @@
#include <IceUtil/Exception.h>
#include <IceUtil/StaticMutex.h>
+#include <IceUtil/StringUtil.h>
#include <ostream>
#include <cstdlib>
@@ -148,7 +149,7 @@ IceUtil::IllegalArgumentException::IllegalArgumentException(const char* file, in
IceUtil::IllegalArgumentException::IllegalArgumentException(const char* file, int line, const string& r) :
Exception(file, line),
- reason(r)
+ _reason(r)
{
}
@@ -164,6 +165,13 @@ IceUtil::IllegalArgumentException::ice_name() const
return _name;
}
+void
+IceUtil::IllegalArgumentException::ice_print(ostream& out) const
+{
+ Exception::ice_print(out);
+ out << ": " << _reason;
+}
+
IceUtil::Exception*
IceUtil::IllegalArgumentException::ice_clone() const
{
@@ -176,10 +184,51 @@ IceUtil::IllegalArgumentException::ice_throw() const
throw *this;
}
-ostream&
-IceUtil::operator<<(ostream& out, const IceUtil::IllegalArgumentException& ex)
+string
+IceUtil::IllegalArgumentException::reason() const
{
- ex.ice_print(out);
- out << ": " << ex.reason;
- return out;
+ return _reason;
+}
+
+IceUtil::SyscallException::SyscallException(const char* file, int line, int err ):
+ Exception(file, line),
+ _error(err)
+{
+}
+
+const char* IceUtil::SyscallException::_name = "IceUtil::SyscallException";
+
+string
+IceUtil::SyscallException::ice_name() const
+{
+ return _name;
+}
+
+void
+IceUtil::SyscallException::ice_print(ostream& os) const
+{
+ Exception::ice_print(os);
+ if(_error != 0)
+ {
+ os << ":\nsyscall exception: " << IceUtilInternal::errorToString(_error);
+ }
}
+
+IceUtil::Exception*
+IceUtil::SyscallException::ice_clone() const
+{
+ return new SyscallException(*this);
+}
+
+void
+IceUtil::SyscallException::ice_throw() const
+{
+ throw *this;
+}
+
+int
+IceUtil::SyscallException::error() const
+{
+ return _error;
+}
+