X-Git-Url: https://git.liburcu.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fcommon%2Fexception.hpp;h=b7e8261ed65217f5652fd88192c37e78c178dd76;hp=b223799151508c5a5a51d37628db093aca9bc6d6;hb=baac5795bc71176909898f7fcbf59dc822f11f4f;hpb=1823e905abb7044e38434cc7d16fdec8545dda1c diff --git a/src/common/exception.hpp b/src/common/exception.hpp index b22379915..b7e8261ed 100644 --- a/src/common/exception.hpp +++ b/src/common/exception.hpp @@ -20,17 +20,30 @@ throw lttng::posix_error(msg, errno_code, __FILE__, __func__, __LINE__) #define LTTNG_THROW_ERROR(msg) \ throw lttng::runtime_error(msg, __FILE__, __func__, __LINE__) +#define LTTNG_THROW_COMMUNICATION_ERROR(msg) \ + throw lttng::communication_error(msg, __FILE__, __func__, __LINE__) +#define LTTNG_THROW_PROTOCOL_ERROR(msg) \ + throw lttng::protocol_error(msg, __FILE__, __func__, __LINE__) +#define LTTNG_THROW_INVALID_ARGUMENT_ERROR(msg) \ + throw lttng::invalid_argument_error(msg, __FILE__, __func__, __LINE__) namespace lttng { +class runtime_error : public std::runtime_error { +public: + explicit runtime_error(const std::string& msg, + const char *file_name, + const char *function_name, + unsigned int line_number); +}; namespace ctl { /* Wrap lttng_error_code errors which may be reported through liblttng-ctl's interface. */ -class error : public std::runtime_error { +class error : public runtime_error { public: explicit error(lttng_error_code error_code, - const char *file_name, - const char *function_name, - unsigned int line_number); + const char *file_name, + const char *function_name, + unsigned int line_number); lttng_error_code get_code() const; private: @@ -40,19 +53,35 @@ private: class posix_error : public std::system_error { public: - explicit posix_error(const std::string &msg, - int errno_code, - const char *file_name, - const char *function_name, - unsigned int line_number); + explicit posix_error(const std::string& msg, + int errno_code, + const char *file_name, + const char *function_name, + unsigned int line_number); }; -class runtime_error : public std::runtime_error { +class communication_error : public runtime_error { +public: + explicit communication_error(const std::string& msg, + const char *file_name, + const char *function_name, + unsigned int line_number); +}; + +class protocol_error : public communication_error { +public: + explicit protocol_error(const std::string& msg, + const char *file_name, + const char *function_name, + unsigned int line_number); +}; + +class invalid_argument_error : public runtime_error { public: - explicit runtime_error(const std::string &msg, - const char *file_name, - const char *function_name, - unsigned int line_number); + explicit invalid_argument_error(const std::string& msg, + const char *file_name, + const char *function_name, + unsigned int line_number); }; }; /* namespace lttng */