X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=src%2Fcommon%2Fexception.cpp;h=028d253f2d885a6c9d9c29a4dc8c875a40b698f2;hb=HEAD;hp=5645d7d91702efe3a0df4779d363fe616acbb78a;hpb=b6bbb1d666531bf061f29884da1b0d7c10f59aa0;p=lttng-tools.git diff --git a/src/common/exception.cpp b/src/common/exception.cpp index 5645d7d91..9288aaa07 100644 --- a/src/common/exception.cpp +++ b/src/common/exception.cpp @@ -6,78 +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) -{ - std::stringstream location; +#include - location << "[" << function_name << "()" - << " " << file_name << ":" << line_number << "]"; +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 } +{ +} - return location.str(); +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) +{ } -} /* namespace */ -lttng::ctl::error::error(lttng_error_code error_code, - 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::runtime_error::runtime_error(const std::string& msg, + const lttng::source_location& location) : + std::runtime_error(msg), source_location(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::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::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::out_of_range::out_of_range(const std::string& msg, const lttng::source_location& location) : + lttng::runtime_error(msg, location) { } 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)) + const lttng::source_location& location) : + lttng::runtime_error(msg, location) { } 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) + const lttng::source_location& location) : + runtime_error(msg, location) { } 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) + const lttng::source_location& location) : + communication_error(msg, location) { } 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) + const lttng::source_location& location) : + runtime_error(msg, location) { }