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>
16 format_throw_location(const char *file_name
, const char *function_name
, unsigned int line_number
)
18 std::stringstream location
;
20 location
<< "[" << function_name
<< "()"
21 << " " << file_name
<< ":" << line_number
<< "]";
23 return location
.str();
27 lttng::ctl::error::error(const std::string
& msg
,
28 lttng_error_code error_code
,
29 const char *file_name
,
30 const char *function_name
,
31 unsigned int line_number
) :
32 runtime_error(msg
+ ": " + std::string(error_get_str(error_code
)),
36 _error_code
{ error_code
}
40 lttng::posix_error::posix_error(const std::string
& msg
,
42 const char *file_name
,
43 const char *function_name
,
44 unsigned int line_number
) :
45 std::system_error(errno_code
,
46 std::generic_category(),
47 msg
+ " " + format_throw_location(file_name
, function_name
, line_number
))
51 lttng::runtime_error::runtime_error(const std::string
& msg
,
52 const char *file_name
,
53 const char *function_name
,
54 unsigned int line_number
) :
55 std::runtime_error(msg
+ " " + format_throw_location(file_name
, function_name
, line_number
))
59 lttng::unsupported_error::unsupported_error(const std::string
& msg
,
60 const char *file_name
,
61 const char *function_name
,
62 unsigned int line_number
) :
63 std::runtime_error(msg
+ " " + format_throw_location(file_name
, function_name
, line_number
))
67 lttng::communication_error::communication_error(const std::string
& msg
,
68 const char *file_name
,
69 const char *function_name
,
70 unsigned int line_number
) :
71 runtime_error(msg
, file_name
, function_name
, line_number
)
75 lttng::protocol_error::protocol_error(const std::string
& msg
,
76 const char *file_name
,
77 const char *function_name
,
78 unsigned int line_number
) :
79 communication_error(msg
, file_name
, function_name
, line_number
)
83 lttng::invalid_argument_error::invalid_argument_error(const std::string
& msg
,
84 const char *file_name
,
85 const char *function_name
,
86 unsigned int line_number
) :
87 runtime_error(msg
, file_name
, function_name
, line_number
)