37 #ifndef _EXCEPTION_HPP_ 38 #define _EXCEPTION_HPP_ 73 Exception(
const std::string& rMessage,
const std::string& rFilename,
unsigned lineNumber);
119 static void Terminate(
const std::string& rMessage,
const std::string& rFilename,
unsigned lineNumber);
131 const std::string& rFilename,
unsigned lineNumber);
143 #define EXCEPTION(message) \ 145 std::stringstream msg_stream; \ 146 msg_stream << message; \ 147 throw Exception(msg_stream.str(), __FILE__, __LINE__); \ 150 #include <boost/preprocessor/stringize.hpp> 158 #define EXCEPT_IF_NOT(test) \ 159 if (!(test)) EXCEPTION("Assertion tripped: " BOOST_PP_STRINGIZE(test)) 168 #define TERMINATE(message) \ 170 std::stringstream msg_stream; \ 171 msg_stream << message; \ 172 Exception::Terminate(msg_stream.str(), __FILE__, __LINE__); \ 206 #define NEVER_REACHED TERMINATE("Should have been impossible to reach this line of code"); exit(EXIT_FAILURE) 214 #define UNUSED_OPT(var) var=var 216 #define UNUSED_OPT(var) 225 #define ABORT_IF_THROWS(block) \ 228 } catch (const Exception& e) { \ 229 TERMINATE(e.GetMessage()); \ 230 } catch (const std::exception &e) { \ 231 TERMINATE(e.what()); \ 233 TERMINATE("Unexpected exception thrown."); \ 254 #define EXPECT0(cmd, arg) { \ 255 std::string _arg(arg); \ 256 int retcode = cmd(_arg.c_str()); \ 257 if (retcode != 0) { \ 258 EXCEPTION("Error executing command: " #cmd "(" + _arg + ")"); \ 270 #define ABORT_IF_NON0_WITH_MSG(retcode, msg) \ 271 if (retcode != 0) { \ 287 #define ABORT_IF_NON0(cmd, arg) { \ 288 std::string _arg(arg); \ 289 int ret = cmd(_arg.c_str()); \ 290 ABORT_IF_NON0_WITH_MSG(ret, "Error executing command: " #cmd "(" + _arg + ")") \ 301 #define EXPECT_NON0(cmd, arg) { \ 302 std::string _arg = (arg); \ 303 int ret = cmd(_arg.c_str()); \ 305 EXCEPTION("Command: " #cmd "(" + _arg + ") succeeded and it shouldn't have"); \ 316 #define IGNORE_RET(cmd, arg) { \ 317 std::string _arg = (arg); \ 318 int ret = cmd(_arg.c_str()); \ 322 #endif // _EXCEPTION_HPP_ std::string CheckShortMessage(std::string expected) const
Exception(const std::string &rMessage, const std::string &rFilename, unsigned lineNumber)
const double DOUBLE_UNSET
void SetMessage(const std::string &rMessage, const std::string &rFilename, unsigned lineNumber)
std::string GetMessage() const
const unsigned UNSIGNED_UNSET
static void Terminate(const std::string &rMessage, const std::string &rFilename, unsigned lineNumber)
std::string mShortMessage
std::string CheckShortMessageContains(std::string expected) const
std::string GetShortMessage() const