X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Fexception.cpp;h=05c30fc6d37d198025d4c8d15433ad269bf96d16;hb=28ab034a2c3582d07d3423d2d746731f87d3969f;hp=cc0011405a69f37e17711e485e43a050c537295f;hpb=aeeb48c6a7dd4bcc092b3105439489fc393f6425;p=lttng-tools.git diff --git a/src/common/exception.cpp b/src/common/exception.cpp index cc0011405..05c30fc6d 100644 --- a/src/common/exception.cpp +++ b/src/common/exception.cpp @@ -6,12 +6,14 @@ */ #include "exception.hpp" -#include + #include +#include + namespace { -std::string format_throw_location( - const char *file_name, const char *function_name, unsigned int line_number) +std::string +format_throw_location(const char *file_name, const char *function_name, unsigned int line_number) { std::stringstream location; @@ -20,32 +22,65 @@ std::string format_throw_location( return location.str(); } -} // namespace +} /* namespace */ lttng::ctl::error::error(lttng_error_code error_code, - const char *file_name, - const char *function_name, - unsigned int line_number) : - std::runtime_error(std::string(error_get_str(error_code)) + " " + - format_throw_location(file_name, function_name, line_number)) + const char *file_name, + const char *function_name, + unsigned int line_number) : + runtime_error( + std::string(error_get_str(error_code)), file_name, function_name, line_number), + _error_code{ error_code } { } -lttng::posix_error::posix_error(const std::string &msg, - int errno_code, - const char *file_name, - const char *function_name, - unsigned int line_number) : +lttng::posix_error::posix_error(const std::string& msg, + int errno_code, + const char *file_name, + const char *function_name, + unsigned int line_number) : std::system_error(errno_code, - std::generic_category(), - msg + " " + format_throw_location(file_name, function_name, line_number)) + std::generic_category(), + msg + " " + format_throw_location(file_name, function_name, line_number)) { } -lttng::runtime_error::runtime_error(const std::string &msg, - const char *file_name, - const char *function_name, - unsigned int line_number) : +lttng::runtime_error::runtime_error(const std::string& msg, + const char *file_name, + const char *function_name, + unsigned int line_number) : std::runtime_error(msg + " " + format_throw_location(file_name, function_name, line_number)) { } + +lttng::unsupported_error::unsupported_error(const std::string& msg, + const char *file_name, + const char *function_name, + unsigned int line_number) : + std::runtime_error(msg + " " + format_throw_location(file_name, function_name, line_number)) +{ +} + +lttng::communication_error::communication_error(const std::string& msg, + const char *file_name, + const char *function_name, + unsigned int line_number) : + runtime_error(msg, file_name, function_name, line_number) +{ +} + +lttng::protocol_error::protocol_error(const std::string& msg, + const char *file_name, + const char *function_name, + unsigned int line_number) : + communication_error(msg, file_name, function_name, line_number) +{ +} + +lttng::invalid_argument_error::invalid_argument_error(const std::string& msg, + const char *file_name, + const char *function_name, + unsigned int line_number) : + runtime_error(msg, file_name, function_name, line_number) +{ +}