9 #ifndef RMF_EXCEPTIONS_H
10 #define RMF_EXCEPTIONS_H
12 #include <boost/exception/exception.hpp>
16 #include "RMF/config.h"
27 class RMFEXPORT
Exception :
public virtual std::exception,
28 public virtual boost::exception {
29 mutable std::string message_;
32 RMF_CXX11_DEFAULT_COPY_CONSTRUCTOR(
Exception);
34 const char* what()
const noexcept
override;
85 #define RMF_THROW(m, e) \
87 using namespace ::RMF::internal::ErrorInfo; \
88 using ::RMF::internal::ErrorInfo::Type; \
89 using ::RMF::internal::ErrorInfo::Category; \
90 using ::RMF::internal::ErrorInfo::Key; \
91 using ::RMF::internal::ErrorInfo::Decorator; \
92 using boost::operator<<; \
96 #define RMF_RETHROW(m, e) \
98 using namespace ::RMF::internal::ErrorInfo; \
99 using ::RMF::internal::ErrorInfo::Type; \
100 using ::RMF::internal::ErrorInfo::Category; \
101 using ::RMF::internal::ErrorInfo::Key; \
102 using ::RMF::internal::ErrorInfo::Decorator; \
103 using boost::operator<<; \
108 #define RMF_USAGE_CHECK(check, message) \
111 RMF_THROW(Message(message) << Type("Usage"), ::RMF::UsageException); \
115 #define RMF_INDEX_CHECK(value, end) \
117 static_cast<unsigned int>(value) < static_cast<unsigned int>(end), \
118 "Out of range index");
120 #define RMF_PATH_CHECK(path) \
121 if (!boost::filesystem::exists(path)) { \
122 RMF_THROW(Message("File does not exist") << File(path) << Type("Usage"), \
127 #define RMF_INTERNAL_CHECK(check, message) \
130 RMF_THROW(Message(message) << Type("Internal") << SourceFile(__FILE__) \
131 << SourceLine(__LINE__) \
132 << Function(BOOST_CURRENT_FUNCTION), \
133 ::RMF::InternalException); \
137 #define RMF_IF_CHECK if (true)
140 #define RMF_INTERNAL_CHECK(check, message)
145 #define RMF_NOT_IMPLEMENTED \
146 RMF_THROW(Message("Not implemented") << Function(BOOST_CURRENT_FUNCTION) \
147 << SourceFile(__FILE__) \
148 << SourceLine(__LINE__) \
149 << Type("NotImplemented"), \
150 ::RMF::InternalException)
154 #include "RMF/internal/errors.h"
std::string get_message(const Exception &e)
Various compiler workarounds.