PdCom  5.1
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 
29 #include <stdexcept>
30 #include <string>
31 
32 namespace PdCom {
33 
34 struct PDCOM5_PUBLIC Exception : std::runtime_error
35 {
36  using std::runtime_error::runtime_error;
37 };
38 
39 struct PDCOM5_PUBLIC InternalError : Exception
40 {
41  InternalError() : Exception("Internal error, please file a bug report") {}
42  InternalError(const std::string &msg) :
43  Exception("Internal error, please file a bug report: " + msg)
44  {}
45 };
46 
48 {
49  using Exception::Exception;
50 };
51 
52 struct PDCOM5_PUBLIC ConnectionFailed : Exception
53 {
54  ConnectionFailed() : Exception("Connection failed") {}
55 };
56 
57 struct PDCOM5_PUBLIC EmptyVariable : Exception
58 {
59  EmptyVariable() : Exception("Variable is empty") {}
60 };
61 
62 struct PDCOM5_PUBLIC InvalidSubscription : Exception
63 {
64  InvalidSubscription() : Exception("invalid subscription") {}
65 };
66 
67 struct PDCOM5_PUBLIC LoginRequired : Exception
68 {
69  LoginRequired() : Exception("Login is required") {}
70 };
71 
72 struct PDCOM5_PUBLIC NotConnected : Exception
73 {
74  NotConnected() : Exception("Not connected") {}
75 };
76 
77 struct PDCOM5_PUBLIC ProcessGoneAway : Exception
78 {
79  ProcessGoneAway() : Exception("Process has gone away") {}
80 };
81 
82 struct PDCOM5_PUBLIC ProtocolError : Exception
83 {
84  using Exception::Exception;
85 };
86 
87 struct PDCOM5_PUBLIC ReadFailure : Exception
88 {
89  int errno_;
90  ReadFailure(int e) :
91  Exception("Read failure, errno: " + std::to_string(e)), errno_(e)
92  {}
93 };
94 
95 struct PDCOM5_PUBLIC TlsError : Exception
96 {
97  TlsError(std::string what, int err_code) :
98  Exception(std::move(what)), err_code_(err_code)
99  {}
100  int err_code_;
101 };
102 
103 struct PDCOM5_PUBLIC WriteFailure : Exception
104 {
105  int errno_;
106  using Exception::Exception;
107  WriteFailure(int e) :
108  Exception("Write failure, errno: " + std::to_string(e)), errno_(e)
109  {}
110 };
111 
112 
113 } // namespace PdCom
114 
115 
116 #endif // PDCOM5_EXCEPTION_H
library version string as "major.minor.patch"
Definition: ClientStatistics.h:31
Definition: Exception.h:53
Definition: Exception.h:58
Definition: Exception.h:35
Definition: Exception.h:40
Definition: Exception.h:48
Definition: Exception.h:63
Definition: Exception.h:68
Definition: Exception.h:73
Definition: Exception.h:78
Definition: Exception.h:83
Definition: Exception.h:88
Definition: Exception.h:96
Definition: Exception.h:104