summaryrefslogtreecommitdiff
path: root/cpp/include/IceUtil/Exception.h
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/include/IceUtil/Exception.h')
-rw-r--r--cpp/include/IceUtil/Exception.h42
1 files changed, 24 insertions, 18 deletions
diff --git a/cpp/include/IceUtil/Exception.h b/cpp/include/IceUtil/Exception.h
index 74a57044479..d21f6269577 100644
--- a/cpp/include/IceUtil/Exception.h
+++ b/cpp/include/IceUtil/Exception.h
@@ -20,6 +20,12 @@ class Exception
{
public:
+ Exception() :
+ _file(0),
+ _line(0)
+ {
+ }
+
Exception(const char* file, int line) :
_file(file),
_line(line)
@@ -40,49 +46,49 @@ public:
{
if (this != &ex)
{
- _line = ex._line;
_file = ex._file;
+ _line = ex._line;
}
return *this;
}
- virtual std::string toString() const
+ virtual std::string _name() const
{
- return debugInfo() + "unknown Ice exception";
+ return "IceUtil::Exception";
}
- virtual Exception* clone() const
+ virtual std::string _description() const
{
- return new Exception(*this);
+ return "unknown Ice exception";
}
- virtual void raise() const
+ virtual Exception* _clone() const
{
- throw *this;
+ return new Exception(*this);
}
-
-protected:
-
- std::string debugInfo() const
+ virtual void _throw() const
{
- std::ostringstream s;
- s << _file << ':' << _line << ": ";
- return s.str();
+ throw *this;
}
-
+
private:
-
+
const char* _file;
int _line;
+ friend std::ostream& operator<<(std::ostream&, const Exception&);
};
inline std::ostream&
operator<<(std::ostream& out, const Exception& ex)
{
- std::string s = ex.toString();
- return out << s;
+ if (ex._file && ex._line > 0)
+ {
+ out << ex._file << ':' << ex._line << ": ";
+ }
+ out << ex._name() << ": " << ex._description();
+ return out;
}
}