2 * Copyright (C) 2022 Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 * SPDX-License-Identifier: LGPL-2.1-only
8 #include "exception.hpp"
10 #include <common/error.hpp>
12 #include <lttng/lttng-error.h>
18 format_throw_location(const char *file_name
, const char *function_name
, unsigned int line_number
)
20 std::stringstream location
;
22 location
<< "[" << function_name
<< "()"
23 << " " << file_name
<< ":" << line_number
<< "]";
25 return location
.str();
29 lttng::ctl::error::error(const std::string
& msg
,
30 lttng_error_code error_code
,
31 const char *file_name
,
32 const char *function_name
,
33 unsigned int line_number
) :
34 runtime_error(msg
+ ": " + std::string(error_get_str(error_code
)),
38 _error_code
{ error_code
}
42 lttng::posix_error::posix_error(const std::string
& msg
,
44 const char *file_name
,
45 const char *function_name
,
46 unsigned int line_number
) :
47 std::system_error(errno_code
,
48 std::generic_category(),
49 msg
+ " " + format_throw_location(file_name
, function_name
, line_number
))
53 lttng::runtime_error::runtime_error(const std::string
& msg
,
54 const char *file_name
,
55 const char *function_name
,
56 unsigned int line_number
) :
57 std::runtime_error(msg
+ " " + format_throw_location(file_name
, function_name
, line_number
))
61 lttng::unsupported_error::unsupported_error(const std::string
& msg
,
62 const char *file_name
,
63 const char *function_name
,
64 unsigned int line_number
) :
65 std::runtime_error(msg
+ " " + format_throw_location(file_name
, function_name
, line_number
))
69 lttng::communication_error::communication_error(const std::string
& msg
,
70 const char *file_name
,
71 const char *function_name
,
72 unsigned int line_number
) :
73 runtime_error(msg
, file_name
, function_name
, line_number
)
77 lttng::protocol_error::protocol_error(const std::string
& msg
,
78 const char *file_name
,
79 const char *function_name
,
80 unsigned int line_number
) :
81 communication_error(msg
, file_name
, function_name
, line_number
)
85 lttng::invalid_argument_error::invalid_argument_error(const std::string
& msg
,
86 const char *file_name
,
87 const char *function_name
,
88 unsigned int line_number
) :
89 runtime_error(msg
, file_name
, function_name
, line_number
)