UniSet 2.32.1
Exceptions.h
1/*
2 * Copyright (c) 2015 Pavel Vainerman.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as
6 * published by the Free Software Foundation, version 2.1.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Lesser Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16// --------------------------------------------------------------------------
21// --------------------------------------------------------------------------
22#ifndef Exceptions_h_
23#define Exceptions_h_
24// ---------------------------------------------------------------------------
25#include <ostream>
26#include <iostream>
27#include <string>
28#include <exception>
29// ---------------------------------------------------------------------
30
31namespace uniset
32{
38 // namespase UniSetExceptions
39
44 class Exception:
45 public std::exception
46 {
47 public:
48
49 Exception(const std::string& txt) noexcept: text(txt) {}
50 Exception() noexcept: text("Exception") {}
51 virtual ~Exception() noexcept(true) {}
52
53 friend std::ostream& operator<<(std::ostream& os, const Exception& ex )
54 {
55 os << ex.text;
56 return os;
57 }
58
59 virtual const char* what() const noexcept override
60 {
61 return text.c_str();
62 }
63
64 protected:
65 const std::string text;
66 };
67
68 class OutOfRange: public Exception
69 {
70 public:
71 OutOfRange() noexcept: Exception("OutOfRange") {}
72 OutOfRange(const std::string& err) noexcept: Exception(err) {}
73 };
74
78 class ORepFailed: public Exception
79 {
80 public:
81 ORepFailed() noexcept: Exception("ORepFailed") {}
82
84 ORepFailed(const std::string& err) noexcept: Exception(err) {}
85 };
86
87
89 class SystemError: public Exception
90 {
91 public:
92 SystemError() noexcept: Exception("SystemError") {}
93
95 SystemError(const std::string& err) noexcept: Exception(err) {}
96 };
97
99 class CommFailed: public Exception
100 {
101 public:
102 CommFailed() noexcept: Exception("CommFailed") {}
103
105 CommFailed(const std::string& err) noexcept: Exception(err) {}
106 };
107
108
113 class TimeOut: public CommFailed
114 {
115 public:
116 TimeOut() noexcept: CommFailed("TimeOut") {}
117
119 TimeOut(const std::string& err) noexcept: CommFailed(err) {}
120
121 };
122
125 {
126 public:
127 ResolveNameError() noexcept: ORepFailed("ResolveNameError") {}
128 ResolveNameError(const std::string& err) noexcept: ORepFailed(err) {}
129 };
130
131
133 {
134 public:
135 NSResolveError() noexcept: ORepFailed("NSResolveError") {}
136 NSResolveError(const std::string& err) noexcept: ORepFailed(err) {}
137 };
138
139
145 {
146 public:
147 ObjectNameAlready() noexcept: ResolveNameError("ObjectNameAlready") {}
148
150 ObjectNameAlready(const std::string& err) noexcept: ResolveNameError(err) {}
151 };
152
157 class IOBadParam: public Exception
158 {
159 public:
160 IOBadParam() noexcept: Exception("IOBadParam") {}
161
163 IOBadParam(const std::string& err) noexcept: Exception(err) {}
164 };
165
171 {
172 public:
173 InvalidObjectName() noexcept: ResolveNameError("InvalidObjectName") {}
174 InvalidObjectName(const std::string& err) noexcept: ResolveNameError(err) {}
175 };
176
178 {
179 public:
180 NameNotFound() noexcept: ResolveNameError("NameNotFound") {}
181 NameNotFound(const std::string& err) noexcept: ResolveNameError(err) {}
182 };
183
185 // end of UniSetException group
186 // ---------------------------------------------------------------------
187} // end of uniset namespace
188// ---------------------------------------------------------------------
189#endif // Exception_h_
190// ---------------------------------------------------------------------
Definition Exceptions.h:100
Definition Exceptions.h:46
Definition Exceptions.h:158
Definition Exceptions.h:171
Definition Exceptions.h:133
Definition Exceptions.h:178
Definition Exceptions.h:79
Definition Exceptions.h:145
Definition Exceptions.h:69
Definition Exceptions.h:125
Definition Exceptions.h:90
Definition Exceptions.h:114
CommFailed(const std::string &err) noexcept
Definition Exceptions.h:105
ObjectNameAlready(const std::string &err) noexcept
Definition Exceptions.h:150
IOBadParam(const std::string &err) noexcept
Definition Exceptions.h:163
ORepFailed(const std::string &err) noexcept
Definition Exceptions.h:84
SystemError(const std::string &err) noexcept
Definition Exceptions.h:95
TimeOut(const std::string &err) noexcept
Definition Exceptions.h:119
Definition Calibration.h:27