summaryrefslogtreecommitdiff
path: root/src/util/exception.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/exception.h')
-rw-r--r--src/util/exception.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/util/exception.h b/src/util/exception.h
index 1b1eb224e..43a0354ca 100644
--- a/src/util/exception.h
+++ b/src/util/exception.h
@@ -30,16 +30,20 @@ namespace CVC4 {
class CVC4_PUBLIC Exception {
protected:
std::string d_msg;
+
public:
// Constructors
Exception() : d_msg("Unknown exception") {}
Exception(const std::string& msg) : d_msg(msg) {}
Exception(const char* msg) : d_msg(msg) {}
+
// Destructor
virtual ~Exception() throw() {}
+
// NON-VIRTUAL METHOD for setting and printing the error message
void setMessage(const std::string& msg) { d_msg = msg; }
std::string getMessage() const { return d_msg; }
+
/**
* Get this exception as a string. Note that
* cout << ex.toString();
@@ -57,16 +61,17 @@ public:
toStream(ss);
return ss.str();
}
+
/**
* Printing: feel free to redefine toStream(). When overridden in
* a derived class, it's recommended that this method print the
* type of exception before the actual message.
*/
virtual void toStream(std::ostream& os) const { os << d_msg; }
- // No need to overload operator<< for the inherited classes
- friend std::ostream& operator<<(std::ostream& os, const Exception& e);
+
};/* class Exception */
+inline std::ostream& operator<<(std::ostream& os, const Exception& e) CVC4_PUBLIC;
inline std::ostream& operator<<(std::ostream& os, const Exception& e) {
e.toStream(os);
return os;
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback