9 #ifndef RAD_EXCEPTIONS_HPP
10 #define RAD_EXCEPTIONS_HPP
12 #include <rad/Helper.hpp>
15 #include <boost/filesystem.hpp>
35 const char*
const CFG_LOAD =
"Loading configuration file";
36 const char*
const OPT_INVALID =
"Invalid command line option";
51 : m_message(BuildWhatArg(msg, info)) {}
55 m_message = e.m_message;
61 if (&e ==
this)
return *
this;
62 std::exception::operator =(e);
63 m_message = e.m_message;
68 m_message = m_message +
"\n" + str;
71 virtual const char*
what()
const throw() {
72 return m_message.c_str();
77 std::string m_message;
80 static const std::string BuildWhatArg(
const std::string&
msg,
const std::string& info)
84 if (info.size() > 0) {
85 s <<
" (" << info <<
")";
119 #define RAD_EXCEPTION_INFO(component, proc_name, version, severity, tag, text)\
121 std::stringstream buf; \
122 buf << rad::GetTimestamp() << " " \
123 << boost::filesystem::path(__FILE__).filename().string() << " " \
124 << __LINE__ << " " << __FUNCTION__ << " " << component << " " \
125 << rad::Helper::GetHostname() << " " << proc_name << " " \
126 << std::hex << std::this_thread::get_id() << " " << getpid() << std::dec << " " \
127 << version << " " << severity << " " << tag << " " << text;
129 #define RAD_THROW(msg, component, proc_name, version, severity, tag) \
131 RAD_EXCEPTION_INFO(component, proc_name, version, severity, tag, "") \
132 throw rad::Exception(msg, buf.str());
134 #define RAD_RETHROW(exception, component, proc_name, version, severity, tag, text) \
136 RAD_EXCEPTION_INFO(component, proc_name, version, severity, tag, text) \
137 exception.AddDiagnostic(buf.str()); \
142 #endif // RAD_EXCEPTIONS_HPP
InvalidOptionException(const std::string ¶m)
Definition: Exceptions.hpp:109
virtual ~RuntimeDbException() noexcept
Definition: Exceptions.hpp:100
const char *const DB_API_NULL
Definition: Exceptions.hpp:27
const char *const MSG_SOCKET_ERR
Definition: Exceptions.hpp:31
void AddDiagnostic(const std::string &str)
Definition: Exceptions.hpp:67
Definition: Exceptions.hpp:106
const char *const DB_REPLY_ERR
Definition: Exceptions.hpp:28
const char *const MSG_BIND_ERR
Definition: Exceptions.hpp:33
RuntimeDbException(const std::string &msg)
Definition: Exceptions.hpp:97
Definition: Exceptions.hpp:94
virtual ~InvalidOptionException() noexcept
Definition: Exceptions.hpp:111
optional string msg
Definition: topics.proto:7
RuntimeDbException(const std::string &msg, const std::string &info)
Definition: Exceptions.hpp:98
Exception(const std::string &msg, const std::string &info)
Definition: Exceptions.hpp:50
Exception(const Exception &e)
Definition: Exceptions.hpp:53
Exception & operator=(const Exception &e)
Definition: Exceptions.hpp:60
const char *const MSG_CONFIG_ERR
Definition: Exceptions.hpp:34
const char *const OPT_INVALID
Definition: Exceptions.hpp:36
Definition: Exceptions.hpp:44
const char *const MSG_CONNECT_ERR
Definition: Exceptions.hpp:32
virtual ~Exception() noexcept
Definition: Exceptions.hpp:58
const char *const MSG_CONTEXT_ERR
Definition: Exceptions.hpp:30
const char *const CFG_LOAD
Definition: Exceptions.hpp:35
Exception(const std::string &msg)
Definition: Exceptions.hpp:47
virtual const char * what() const
Definition: Exceptions.hpp:71
const char *const DB_CONTEXT_ERR
Definition: Exceptions.hpp:29