diff options
author | Michi Henning <michi@zeroc.com> | 2007-03-19 03:31:04 +0000 |
---|---|---|
committer | Michi Henning <michi@zeroc.com> | 2007-03-19 03:31:04 +0000 |
commit | 55538ff830b8f462a2a9cd8d9caf892f91803d8b (patch) | |
tree | 33b1244f198daf7da400156123629d85a198e577 /cpp/src/IceUtil/Exception.cpp | |
parent | Fixed bug 2005 (diff) | |
download | ice-55538ff830b8f462a2a9cd8d9caf892f91803d8b.tar.bz2 ice-55538ff830b8f462a2a9cd8d9caf892f91803d8b.tar.xz ice-55538ff830b8f462a2a9cd8d9caf892f91803d8b.zip |
Bug 2048.
Diffstat (limited to 'cpp/src/IceUtil/Exception.cpp')
-rw-r--r-- | cpp/src/IceUtil/Exception.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/cpp/src/IceUtil/Exception.cpp b/cpp/src/IceUtil/Exception.cpp index adcced92d33..5208bfe0a2d 100644 --- a/cpp/src/IceUtil/Exception.cpp +++ b/cpp/src/IceUtil/Exception.cpp @@ -8,6 +8,8 @@ // ********************************************************************** #include <IceUtil/Exception.h> +#include <IceUtil/StaticMutex.h> +#include <ostream> using namespace std; @@ -52,6 +54,21 @@ IceUtil::Exception::ice_print(ostream& out) const out << ice_name(); } +const char* +IceUtil::Exception::what() const throw() +{ + StaticMutex::Lock lock(globalMutex); + { + if(_str.empty()) + { + stringstream s; + ice_print(s); + _str = s.str(); // Lazy initialization. + } + } + return _str.c_str(); +} + IceUtil::Exception* IceUtil::Exception::ice_clone() const { @@ -154,7 +171,7 @@ IceUtil::IllegalArgumentException::ice_throw() const ostream& IceUtil::operator<<(ostream& out, const IceUtil::IllegalArgumentException& ex) { - ex.ice_print(out);
+ ex.ice_print(out); out << ": " << ex.reason; return out; } |