Fix: syscall event rule: emission sites not compared in is_equal
[lttng-tools.git] / src / common / exception.cpp
CommitLineData
53cd1e22
JG
1/*
2 * Copyright (C) 2022 Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 *
4 * SPDX-License-Identifier: LGPL-2.1-only
5 *
6 */
7
8#include "exception.hpp"
28ab034a 9
53cd1e22
JG
10#include <common/error.hpp>
11
28ab034a
JG
12#include <sstream>
13
53cd1e22 14namespace {
28ab034a
JG
15std::string
16format_throw_location(const char *file_name, const char *function_name, unsigned int line_number)
53cd1e22
JG
17{
18 std::stringstream location;
19
20 location << "[" << function_name << "()"
21 << " " << file_name << ":" << line_number << "]";
22
23 return location.str();
24}
baac5795 25} /* namespace */
53cd1e22 26
0038180d
JG
27lttng::ctl::error::error(const std::string& msg,
28 lttng_error_code error_code,
28ab034a
JG
29 const char *file_name,
30 const char *function_name,
31 unsigned int line_number) :
0038180d
JG
32 runtime_error(msg + ": " + std::string(error_get_str(error_code)),
33 file_name,
34 function_name,
35 line_number),
28ab034a 36 _error_code{ error_code }
53cd1e22
JG
37{
38}
39
baac5795 40lttng::posix_error::posix_error(const std::string& msg,
28ab034a
JG
41 int errno_code,
42 const char *file_name,
43 const char *function_name,
44 unsigned int line_number) :
53cd1e22 45 std::system_error(errno_code,
28ab034a
JG
46 std::generic_category(),
47 msg + " " + format_throw_location(file_name, function_name, line_number))
53cd1e22
JG
48{
49}
aeeb48c6 50
baac5795 51lttng::runtime_error::runtime_error(const std::string& msg,
28ab034a
JG
52 const char *file_name,
53 const char *function_name,
54 unsigned int line_number) :
aeeb48c6
JG
55 std::runtime_error(msg + " " + format_throw_location(file_name, function_name, line_number))
56{
57}
baac5795 58
b6bbb1d6 59lttng::unsupported_error::unsupported_error(const std::string& msg,
28ab034a
JG
60 const char *file_name,
61 const char *function_name,
62 unsigned int line_number) :
b6bbb1d6
JG
63 std::runtime_error(msg + " " + format_throw_location(file_name, function_name, line_number))
64{
65}
66
baac5795 67lttng::communication_error::communication_error(const std::string& msg,
28ab034a
JG
68 const char *file_name,
69 const char *function_name,
70 unsigned int line_number) :
baac5795
JG
71 runtime_error(msg, file_name, function_name, line_number)
72{
73}
74
75lttng::protocol_error::protocol_error(const std::string& msg,
28ab034a
JG
76 const char *file_name,
77 const char *function_name,
78 unsigned int line_number) :
baac5795
JG
79 communication_error(msg, file_name, function_name, line_number)
80{
81}
82
83lttng::invalid_argument_error::invalid_argument_error(const std::string& msg,
28ab034a
JG
84 const char *file_name,
85 const char *function_name,
86 unsigned int line_number) :
baac5795
JG
87 runtime_error(msg, file_name, function_name, line_number)
88{
89}
This page took 0.043731 seconds and 4 git commands to generate.