UniSet  1.4.0
Exceptions.h
См. документацию.
00001 /* This file is part of the UniSet project
00002  * Copyright (c) 2002 Free Software Foundation, Inc.
00003  * Copyright (c) 2002 Pavel Vainerman
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; either version 2 of the License, or
00008  * (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00018  */
00019 // --------------------------------------------------------------------------
00024 // -------------------------------------------------------------------------- 
00025 #ifndef Exceptions_h_
00026 #define Exceptions_h_
00027 // ---------------------------------------------------------------------------
00028 #include <ostream>
00029 #include <iostream>
00030 #include <exception>
00031 // ---------------------------------------------------------------------
00032 
00033 namespace UniSetTypes
00034 {
00035     
00041 // namespase UniSetExceptions
00042 
00047 class Exception:
00048     public std::exception
00049 {
00050 public:
00051     void printException() 
00052     { 
00053         std::cerr << "Exception: " << text << std::endl;
00054     }
00055 
00056     Exception(const std::string& txt):text(txt.c_str()){}
00057     Exception():text("Exception"){}
00058     virtual ~Exception() throw(){}
00059 
00060     friend std::ostream& operator<<(std::ostream& os, Exception& ex )
00061     {
00062         os << ex.text;
00063         return os;
00064     }
00065 
00066     virtual const char* what() { return text.c_str(); }
00067     
00068 protected:
00069     const std::string text;
00070 };
00071 
00072 
00073 class PermissionDenied: public Exception
00074 {
00075 public:
00076     PermissionDenied():Exception("PermissionDenied"){}
00077 };
00078 
00079 class NotEnoughMemory: public Exception
00080 {
00081 public:
00082     NotEnoughMemory():Exception("NotEnoughMemory"){}
00083 };
00084 
00085 
00086 class OutOfRange: public Exception
00087 {
00088 public:
00089     OutOfRange():Exception("OutOfRange"){}
00090     OutOfRange(const std::string err):Exception(err){}
00091 };
00092 
00093 
00094 class ErrorHandleResource: public Exception
00095 {
00096 public:
00097     ErrorHandleResource():Exception("ErrorHandleResource"){}
00098 };
00099 
00104 class LimitWaitingPTimers: public Exception
00105 {
00106 public:
00107     LimitWaitingPTimers():Exception("LimitWaitingPassiveTimers"){}
00108     
00110     LimitWaitingPTimers(const std::string err):Exception(err){}
00111 };
00112 
00113 
00118 class ORepFailed: public Exception
00119 {
00120 public:
00121     ORepFailed():Exception("ORepFailed"){}
00122     
00124     ORepFailed(const std::string err):Exception(err){}
00125 };
00126 
00127 
00131 class SystemError: public Exception
00132 {
00133 public:
00134     SystemError():Exception("SystemError"){}
00135     
00137     SystemError(const std::string err):Exception(err){}
00138 };
00139 
00140 class CRCError: public Exception
00141 {
00142 public:
00143     CRCError():Exception("CRCError"){}
00144 };
00145 
00146 
00150 class CommFailed: public Exception
00151 {
00152 public:
00153     CommFailed():Exception("CommFailed"){}
00154     
00156     CommFailed(const std::string err):Exception(err){}
00157 };
00158 
00159 
00164 class TimeOut: public CommFailed
00165 {
00166     public:
00167         TimeOut():CommFailed("TimeOut") {}
00168 
00170     TimeOut(const std::string err):CommFailed(err){}
00171 
00172 };
00173 
00177 class ResolveNameError: public ORepFailed
00178 {
00179     public:
00180         ResolveNameError():ORepFailed("ResolveNameError"){}
00181         ResolveNameError(const std::string err):ORepFailed(err){}
00182 };
00183 
00184 
00185 class NSResolveError: public ORepFailed
00186 {
00187     public:
00188         NSResolveError():ORepFailed("NSResolveError"){}
00189         NSResolveError(const std::string err):ORepFailed(err){}
00190 };
00191 
00192 
00197 class ObjectNameAlready: public ResolveNameError
00198 {
00199 public:
00200     ObjectNameAlready():ResolveNameError("ObjectNameAlready"){}
00201     
00203     ObjectNameAlready(const std::string err):ResolveNameError(err){}
00204 };
00205 
00210 class IOBadParam: public Exception
00211 {
00212     public:
00213     IOBadParam():Exception("IOBadParam"){}
00214     
00216     IOBadParam(const std::string err):Exception(err){}
00217 };
00218 
00223 class InvalidObjectName: public ResolveNameError
00224 {
00225     public:
00226         InvalidObjectName():ResolveNameError("InvalidObjectName"){}
00227         InvalidObjectName(const std::string err):ResolveNameError(err){}
00228 };
00229 
00231 class NotSetSignal: public Exception
00232 {
00233     public:
00234         NotSetSignal():Exception("NotSetSignal"){}
00235         NotSetSignal(const std::string err):Exception(err){}
00236 };
00237 
00238 class NameNotFound: public ResolveNameError
00239 {
00240 public:
00241     NameNotFound():ResolveNameError("NameNotFound"){}
00242     NameNotFound(const std::string err):ResolveNameError(err){}
00243 };
00244 
00246 // end of UniSetException group
00247 // ---------------------------------------------------------------------
00248 }   // end of UniSetTypes namespace
00249 // ---------------------------------------------------------------------
00250 #endif // Exception_h_
00251 // ---------------------------------------------------------------------