21 #ifndef OPM_ERRORMACROS_HPP
22 #define OPM_ERRORMACROS_HPP
24 #include <opm/common/OpmLog/OpmLog.hpp>
35 # define OPM_REPORT do { std::cerr << "[" << __FILE__ << ":" << __LINE__ << "] " } while (false)
36 # define OPM_MESSAGE(x) do { OPM_REPORT; std::cerr << x << "\n"; } while (false)
37 # define OPM_MESSAGE_IF(cond, m) do {if(cond) OPM_MESSAGE(m);} while (false)
39 # define OPM_REPORT do {} while (false)
40 # define OPM_MESSAGE(x) do {} while (false)
41 # define OPM_MESSAGE_IF(cond, m) do {} while (false)
52 #define OPM_THROW(Exception, message) \
54 std::ostringstream opmErrorMacroOStringStream; \
55 opmErrorMacroOStringStream << "[" << __FILE__ << ":" << __LINE__ << "] " << message; \
56 ::Opm::OpmLog::error(opmErrorMacroOStringStream.str()); \
57 throw Exception(opmErrorMacroOStringStream.str()); \
63 #define OPM_THROW_NOLOG(Exception, message) \
65 std::ostringstream opmErrorMacroOStringStream; \
66 opmErrorMacroOStringStream << "[" << __FILE__ << ":" << __LINE__ << "] " << message; \
67 throw Exception(opmErrorMacroOStringStream.str()); \
71 #define OPM_ERROR_IF(condition, message) do {if(condition){ OPM_THROW(std::logic_error, message);}} while(false)