Use compiler-agnostic defines to silence warning
[lttng-tools.git] / src / common / exception.cpp
index 16e27e52afa35ebd4e144363772c839602995e78..9288aaa07924ab0e645f58efdb37ed59024b6d28 100644 (file)
@@ -6,38 +6,63 @@
  */
 
 #include "exception.hpp"
-#include <sstream>
+
 #include <common/error.hpp>
 
-namespace {
-std::string format_throw_location(
-       const char *file_name, const char *function_name, unsigned int line_number)
+#include <sstream>
+
+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)
 {
 }
This page took 0.024093 seconds and 4 git commands to generate.