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(lttng_error_code error_code
,
28 const char *file_name
,
29 const char *function_name
,
30 unsigned int line_number
) :
32 std::string(error_get_str(error_code
)), file_name
, function_name
, line_number
),
33 _error_code
{ error_code
}
37 lttng::posix_error::posix_error(const std::string
& msg
,
39 const char *file_name
,
40 const char *function_name
,
41 unsigned int line_number
) :
42 std::system_error(errno_code
,
43 std::generic_category(),
44 msg
+ " " + format_throw_location(file_name
, function_name
, line_number
))
48 lttng::runtime_error::runtime_error(const std::string
& msg
,
49 const char *file_name
,
50 const char *function_name
,
51 unsigned int line_number
) :
52 std::runtime_error(msg
+ " " + format_throw_location(file_name
, function_name
, line_number
))
56 lttng::unsupported_error::unsupported_error(const std::string
& msg
,
57 const char *file_name
,
58 const char *function_name
,
59 unsigned int line_number
) :
60 std::runtime_error(msg
+ " " + format_throw_location(file_name
, function_name
, line_number
))
64 lttng::communication_error::communication_error(const std::string
& msg
,
65 const char *file_name
,
66 const char *function_name
,
67 unsigned int line_number
) :
68 runtime_error(msg
, file_name
, function_name
, line_number
)
72 lttng::protocol_error::protocol_error(const std::string
& msg
,
73 const char *file_name
,
74 const char *function_name
,
75 unsigned int line_number
) :
76 communication_error(msg
, file_name
, function_name
, line_number
)
80 lttng::invalid_argument_error::invalid_argument_error(const std::string
& msg
,
81 const char *file_name
,
82 const char *function_name
,
83 unsigned int line_number
) :
84 runtime_error(msg
, file_name
, function_name
, line_number
)