Mercurial > dedupe
diff Exception/Exception.hpp @ 28:b2c2c2bf2bbd
Refactor Exceptions into a separate directory.
| author | Tom Fredrik Blenning Klaussen <bfg@blenning.no> |
|---|---|
| date | Thu, 06 Sep 2012 18:29:43 +0200 |
| parents | Exception.hpp@06166d6c083b |
| children | c9447697609f |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Exception/Exception.hpp Thu Sep 06 18:29:43 2012 +0200 @@ -0,0 +1,32 @@ +#ifndef EXCEPTION_HPP +#define EXCEPTION_HPP + +#include <QtCore/QString> + +class Exception { + +public: + typedef QString string_t; + + virtual const string_t& toString() const + { + return errorMsg_; + } + void raise() const + { + throw *this; + } + + +protected: + Exception(const string_t& errorMsg = string_t()) : errorMsg_(errorMsg) {} + virtual ~Exception() {} + + void setErrorMsg(string_t& errorMsg); + const string_t& errorMsg(string_t& errorMsg); + +private: + string_t errorMsg_; +}; + +#endif //EXCEPTION_HPP
