UniSet  2.6.0
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 
31 namespace 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.c_str()) {}
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:68
Definition: CallbackTimer.h:29
Definition: Exceptions.h:78
Definition: Exceptions.h:44
Definition: Exceptions.h:132
TimeOut(const std::string &err) noexcept
Definition: Exceptions.h:119
CommFailed(const std::string &err) noexcept
Definition: Exceptions.h:105
Definition: Exceptions.h:157
Definition: Exceptions.h:170
Definition: Exceptions.h:113
SystemError(const std::string &err) noexcept
Definition: Exceptions.h:95
Definition: Exceptions.h:124
Definition: Exceptions.h:89
Definition: Exceptions.h:177
ObjectNameAlready(const std::string &err) noexcept
Definition: Exceptions.h:150
Definition: Exceptions.h:99
ORepFailed(const std::string &err) noexcept
Definition: Exceptions.h:84
IOBadParam(const std::string &err) noexcept
Definition: Exceptions.h:163
Definition: Exceptions.h:144