2 * Copyright (C) 2022 Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 * SPDX-License-Identifier: LGPL-2.1-only
8 #ifndef LTTNG_EXCEPTION_H_
9 #define LTTNG_EXCEPTION_H_
13 #include <system_error>
15 #include <lttng/lttng-error.h>
17 #define LTTNG_THROW_CTL(error_code) \
18 throw lttng::ctl::error(msg, error_code, __FILE__, __func__, __LINE__)
19 #define LTTNG_THROW_POSIX(msg, errno_code) \
20 throw lttng::posix_error(msg, errno_code, __FILE__, __func__, __LINE__)
25 /* Wrap lttng_error_code errors which may be reported through liblttng-ctl's interface. */
26 class error : public std::runtime_error {
28 explicit error(lttng_error_code error_code,
29 const char *file_name,
30 const char *function_name,
31 unsigned int line_number);
32 lttng_error_code get_code() const;
35 lttng_error_code _error_code;
39 class posix_error : public std::system_error {
41 explicit posix_error(const std::string &msg,
43 const char *file_name,
44 const char *function_name,
45 unsigned int line_number);
48 }; /* namespace lttng */
50 #endif /* LTTNG_EXCEPTION_H_ */