X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Fexception.cpp;h=028d253f2d885a6c9d9c29a4dc8c875a40b698f2;hb=4dfb0ef75c09bbf166e2bd6388e0e07c6af49b20;hp=16e27e52afa35ebd4e144363772c839602995e78;hpb=53cd1e2272afac08649dc55e395ec8a5dac20b4e;p=lttng-tools.git diff --git a/src/common/exception.cpp b/src/common/exception.cpp index 16e27e52a..028d253f2 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,24 +22,68 @@ 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)) +lttng::ctl::error::error(const std::string& msg, + lttng_error_code error_code, + const char *file_name, + const char *function_name, + unsigned int line_number) : + runtime_error(msg + ": " + 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) : + 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) { }