X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fcommon%2Fexception.cpp;h=028d253f2d885a6c9d9c29a4dc8c875a40b698f2;hb=HEAD;hp=16e27e52afa35ebd4e144363772c839602995e78;hpb=53cd1e2272afac08649dc55e395ec8a5dac20b4e;p=lttng-tools.git diff --git a/src/common/exception.cpp b/src/common/exception.cpp index 16e27e52a..9288aaa07 100644 --- a/src/common/exception.cpp +++ b/src/common/exception.cpp @@ -6,38 +6,63 @@ */ #include "exception.hpp" -#include + #include -namespace { -std::string format_throw_location( - const char *file_name, const char *function_name, unsigned int line_number) +#include + +lttng::ctl::error::error(const std::string& msg, + lttng_error_code error_code, + const lttng::source_location& location) : + runtime_error(msg, location), _error_code{ error_code } +{ +} + +lttng::posix_error::posix_error(const std::string& msg, + unsigned int errno_code, + const lttng::source_location& location) : + std::system_error(errno_code, std::generic_category()), lttng::runtime_error(msg, location) +{ +} + +lttng::runtime_error::runtime_error(const std::string& msg, + const lttng::source_location& location) : + std::runtime_error(msg), source_location(location) { - std::stringstream location; +} + +lttng::allocation_failure::allocation_failure(const std::string& msg, + std::size_t allocation_size_, + const lttng::source_location& location) : + lttng::runtime_error(msg, location), allocation_size(allocation_size_) +{ +} + +lttng::out_of_range::out_of_range(const std::string& msg, const lttng::source_location& location) : + lttng::runtime_error(msg, location) +{ +} - location << "[" << function_name << "()" - << " " << file_name << ":" << line_number << "]"; +lttng::unsupported_error::unsupported_error(const std::string& msg, + const lttng::source_location& location) : + lttng::runtime_error(msg, location) +{ +} - return location.str(); +lttng::communication_error::communication_error(const std::string& msg, + const lttng::source_location& location) : + runtime_error(msg, location) +{ } -} // 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::protocol_error::protocol_error(const std::string& msg, + const lttng::source_location& location) : + communication_error(msg, location) { } -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)) +lttng::invalid_argument_error::invalid_argument_error(const std::string& msg, + const lttng::source_location& location) : + runtime_error(msg, location) { }