PdCom  5.3
Process data communication client
Exception.h
Go to the documentation of this file.
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 
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 struct PDCOM5_PUBLIC Exception : std::runtime_error
34 {
35  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 struct PDCOM5_PUBLIC InvalidArgument : Exception
47 {
48  using Exception::Exception;
49 };
50 
51 struct PDCOM5_PUBLIC ConnectionFailed : Exception
52 {
53  ConnectionFailed() : Exception("Connection failed") {}
54 };
55 
56 struct PDCOM5_PUBLIC EmptyVariable : Exception
57 {
58  EmptyVariable() : Exception("Variable is empty") {}
59 };
60 
61 struct PDCOM5_PUBLIC InvalidSubscription : Exception
62 {
63  InvalidSubscription() : Exception("invalid subscription") {}
64 };
65 
66 struct PDCOM5_PUBLIC LoginRequired : Exception
67 {
68  LoginRequired() : Exception("Login is required") {}
69 };
70 
71 struct PDCOM5_PUBLIC NotConnected : Exception
72 {
73  NotConnected() : Exception("Not connected") {}
74 };
75 
76 struct PDCOM5_PUBLIC ProcessGoneAway : Exception
77 {
78  ProcessGoneAway() : Exception("Process has gone away") {}
79 };
80 
81 struct PDCOM5_PUBLIC ProtocolError : Exception
82 {
83  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 struct PDCOM5_PUBLIC WriteFailure : Exception
103 {
104  int errno_;
105  using Exception::Exception;
106  WriteFailure(int e) :
107  Exception("Write failure, errno: " + std::to_string(e)), errno_(e)
108  {}
109 };
110 
111 
112 } // namespace PdCom
113 
114 
115 #endif // PDCOM5_EXCEPTION_H
Definition: Exception.h:76
Definition: Exception.h:94
Definition: Exception.h:33
Definition: Exception.h:61
Definition: Exception.h:38
Definition: Exception.h:66
Definition: Exception.h:81
Definition: Exception.h:51
Definition: Exception.h:56
Definition: Exception.h:102
Definition: Exception.h:86
Definition: ClientStatistics.h:31
Definition: Exception.h:71
Definition: Exception.h:46