UniSet  2.6.0
Exceptions.h
00001 /*
00002  * Copyright (c) 2015 Pavel Vainerman.
00003  *
00004  * This program is free software: you can redistribute it and/or modify
00005  * it under the terms of the GNU Lesser General Public License as
00006  * published by the Free Software Foundation, version 2.1.
00007  *
00008  * This program is distributed in the hope that it will be useful, but
00009  * WITHOUT ANY WARRANTY; without even the implied warranty of
00010  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00011  * Lesser General Lesser Public License for more details.
00012  *
00013  * You should have received a copy of the GNU Lesser General Public License
00014  * along with this program. If not, see <http://www.gnu.org/licenses/>.
00015  */
00016 // --------------------------------------------------------------------------
00021 // --------------------------------------------------------------------------
00022 #ifndef Exceptions_h_
00023 #define Exceptions_h_
00024 // ---------------------------------------------------------------------------
00025 #include <ostream>
00026 #include <iostream>
00027 #include <string>
00028 #include <exception>
00029 // ---------------------------------------------------------------------
00030 
00031 namespace uniset
00032 {
00038 // namespase UniSetExceptions
00039 
00044 class Exception:
00045     public std::exception
00046 {
00047     public:
00048 
00049         Exception(const std::string& txt) noexcept: text(txt.c_str()) {}
00050         Exception() noexcept: text("Exception") {}
00051         virtual ~Exception() noexcept(true) {}
00052 
00053         friend std::ostream& operator<<(std::ostream& os, const Exception& ex )
00054         {
00055             os << ex.text;
00056             return os;
00057         }
00058 
00059         virtual const char* what() const noexcept override
00060         {
00061             return text.c_str();
00062         }
00063 
00064     protected:
00065         const std::string text;
00066 };
00067 
00068 class OutOfRange: public Exception
00069 {
00070     public:
00071         OutOfRange() noexcept: Exception("OutOfRange") {}
00072         OutOfRange(const std::string& err) noexcept: Exception(err) {}
00073 };
00074 
00078 class ORepFailed: public Exception
00079 {
00080     public:
00081         ORepFailed() noexcept: Exception("ORepFailed") {}
00082 
00084         ORepFailed(const std::string& err) noexcept: Exception(err) {}
00085 };
00086 
00087 
00089 class SystemError: public Exception
00090 {
00091     public:
00092         SystemError() noexcept: Exception("SystemError") {}
00093 
00095         SystemError(const std::string& err) noexcept: Exception(err) {}
00096 };
00097 
00099 class CommFailed: public Exception
00100 {
00101     public:
00102         CommFailed() noexcept: Exception("CommFailed") {}
00103 
00105         CommFailed(const std::string& err) noexcept: Exception(err) {}
00106 };
00107 
00108 
00113 class TimeOut: public CommFailed
00114 {
00115     public:
00116         TimeOut() noexcept: CommFailed("TimeOut") {}
00117 
00119         TimeOut(const std::string& err) noexcept: CommFailed(err) {}
00120 
00121 };
00122 
00124 class ResolveNameError: public ORepFailed
00125 {
00126     public:
00127         ResolveNameError() noexcept: ORepFailed("ResolveNameError") {}
00128         ResolveNameError(const std::string& err) noexcept: ORepFailed(err) {}
00129 };
00130 
00131 
00132 class NSResolveError: public ORepFailed
00133 {
00134     public:
00135         NSResolveError() noexcept: ORepFailed("NSResolveError") {}
00136         NSResolveError(const std::string& err) noexcept: ORepFailed(err) {}
00137 };
00138 
00139 
00144 class ObjectNameAlready: public ResolveNameError
00145 {
00146     public:
00147         ObjectNameAlready() noexcept: ResolveNameError("ObjectNameAlready") {}
00148 
00150         ObjectNameAlready(const std::string& err) noexcept: ResolveNameError(err) {}
00151 };
00152 
00157 class IOBadParam: public Exception
00158 {
00159     public:
00160         IOBadParam() noexcept: Exception("IOBadParam") {}
00161 
00163         IOBadParam(const std::string& err) noexcept: Exception(err) {}
00164 };
00165 
00170 class InvalidObjectName: public ResolveNameError
00171 {
00172     public:
00173         InvalidObjectName() noexcept: ResolveNameError("InvalidObjectName") {}
00174         InvalidObjectName(const std::string& err) noexcept: ResolveNameError(err) {}
00175 };
00176 
00177 class NameNotFound: public ResolveNameError
00178 {
00179     public:
00180         NameNotFound() noexcept: ResolveNameError("NameNotFound") {}
00181         NameNotFound(const std::string& err) noexcept: ResolveNameError(err) {}
00182 };
00183 
00185 // end of UniSetException group
00186 // ---------------------------------------------------------------------
00187 }   // end of uniset namespace
00188 // ---------------------------------------------------------------------
00189 #endif // Exception_h_
00190 // ---------------------------------------------------------------------