GCC Code Coverage Report


Directory: ./
File: include/pdcom5/Exception.h
Date: 2024-02-26 09:07:35
Exec Total Coverage
Lines: 21 32 65.6%
Branches: 2 10 20.0%

Line Branch Exec Source
1 /*****************************************************************************
2 *
3 * Copyright (C) 2021 Bjarne von Horn (vh at igh dot de).
4 *
5 * This file is part of the PdCom library.
6 *
7 * The PdCom library is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * The PdCom library is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15 * License for more .
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with the PdCom library. If not, see <http://www.gnu.org/licenses/>.
19 *
20 *****************************************************************************/
21
22 /** @file */
23
24 #ifndef PDCOM5_EXCEPTION_H
25 #define PDCOM5_EXCEPTION_H
26
27 #include <pdcom5_export.h>
28 #include <stdexcept>
29 #include <string>
30
31 namespace PdCom {
32
33 235 struct PDCOM5_PUBLIC Exception : std::runtime_error
34 {
35 235 using std::runtime_error::runtime_error;
36 };
37
38 struct PDCOM5_PUBLIC InternalError : Exception
39 {
40 InternalError() : Exception("Internal error, please file a bug report") {}
41 InternalError(const std::string &msg) :
42 Exception("Internal error, please file a bug report: " + msg)
43 {}
44 };
45
46 25 struct PDCOM5_PUBLIC InvalidArgument : Exception
47 {
48 25 using Exception::Exception;
49 };
50
51 2 struct PDCOM5_PUBLIC ConnectionFailed : Exception
52 {
53 2 ConnectionFailed() : Exception("Connection failed") {}
54 };
55
56 20 struct PDCOM5_PUBLIC EmptyVariable : Exception
57 {
58 20 EmptyVariable() : Exception("Variable is empty") {}
59 };
60
61 34 struct PDCOM5_PUBLIC InvalidSubscription : Exception
62 {
63 34 InvalidSubscription() : Exception("invalid subscription") {}
64 };
65
66 struct PDCOM5_PUBLIC LoginRequired : Exception
67 {
68 LoginRequired() : Exception("Login is required") {}
69 };
70
71 12 struct PDCOM5_PUBLIC NotConnected : Exception
72 {
73 12 NotConnected() : Exception("Not connected") {}
74 };
75
76 130 struct PDCOM5_PUBLIC ProcessGoneAway : Exception
77 {
78 130 ProcessGoneAway() : Exception("Process has gone away") {}
79 };
80
81 1 struct PDCOM5_PUBLIC ProtocolError : Exception
82 {
83 1 using Exception::Exception;
84 };
85
86 struct PDCOM5_PUBLIC ReadFailure : Exception
87 {
88 int errno_;
89 ReadFailure(int e) :
90 Exception("Read failure, errno: " + std::to_string(e)), errno_(e)
91 {}
92 };
93
94 struct PDCOM5_PUBLIC TlsError : Exception
95 {
96 TlsError(std::string what, int err_code) :
97 Exception(std::move(what)), err_code_(err_code)
98 {}
99 int err_code_;
100 };
101
102 11 struct PDCOM5_PUBLIC WriteFailure : Exception
103 {
104 int errno_;
105 4 using Exception::Exception;
106 7 WriteFailure(int e) :
107
2/4
✓ Branch 6 taken 7 times.
✗ Branch 7 not taken.
✓ Branch 10 taken 7 times.
✗ Branch 11 not taken.
7 Exception("Write failure, errno: " + std::to_string(e)), errno_(e)
108 7 {}
109 };
110
111
112 } // namespace PdCom
113
114
115 #endif // PDCOM5_EXCEPTION_H
116