ucommon
exception.h
Go to the documentation of this file.
1 // Copyright (C) 1999-2005 Open Source Telecom Corporation.
2 // Copyright (C) 2006-2014 David Sugar, Tycho Softworks.
3 //
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 2 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU Lesser General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 //
17 // As a special exception, you may use this file as part of a free software
18 // library without restriction. Specifically, if other files instantiate
19 // templates or use macros or inline functions from this file, or you compile
20 // this file and link it with other files to produce an executable, this
21 // file does not by itself cause the resulting executable to be covered by
22 // the GNU General Public License. This exception does not however
23 // invalidate any other reasons why the executable file might be covered by
24 // the GNU General Public License.
25 //
26 // This exception applies only to the code released under the name GNU
27 // Common C++. If you copy code from other releases into a copy of GNU
28 // Common C++, as the General Public License permits, the exception does
29 // not apply to the code that you add in this way. To avoid misleading
30 // anyone as to the status of such modified files, you must delete
31 // this exception notice from them.
32 //
33 // If you write modifications of your own for GNU Common C++, it is your choice
34 // whether to permit this exception to apply to your modifications.
35 // If you do not wish that, delete this exception notice.
36 //
37 
43 #ifndef COMMONCPP_EXCEPTION_H_
44 #define COMMONCPP_EXCEPTION_H_
45 
46 #ifndef COMMONCPP_CONFIG_H_
47 #include <commoncpp/config.h>
48 #endif
49 
50 #ifndef COMMONCPP_STRING_H_
51 #include <commoncpp/string.h>
52 #endif
53 
54 // see if we support useful and std exception handling, else we ignore
55 // it for the rest of the system.
56 
57 #if defined(CCXX_EXCEPTIONS)
58 #define COMMONCPP_EXCEPTIONS
59 
60 #include <exception>
61 #include <stdexcept>
62 
63 namespace ost {
64 
73 class __EXPORT Exception : public std::exception
74 {
75 private:
76  String _what;
77 
78 public:
79  Exception(const String& what_arg) throw();
80  virtual ~Exception() throw();
81  virtual const char *getString() const;
82  virtual const char *what() const throw();
83 };
84 
91 class __EXPORT IOException : public Exception
92 {
93 private:
94  long _systemError;
95  mutable char* _systemErrorString;
96 
97 public:
98  IOException(const String &what_arg, long systemError = 0) throw();
99  virtual ~IOException() throw();
100 
101  virtual long getSystemError() const throw();
102  virtual const char* getSystemErrorString() const throw();
103 };
104 
111 class __EXPORT ThrException : public Exception
112 {
113 public:
114  inline ThrException(const String &what_arg) : Exception(what_arg) {}
115 };
116 
123 class __EXPORT SyncException : public ThrException
124 {
125 public:
126  inline SyncException(const String &what_arg) : ThrException(what_arg) {}
127 };
128 
129 class __EXPORT InterruptException : public ThrException
130 {
131 public:
132  inline InterruptException() : ThrException("interrupted") {}
133 };
134 
135 } // namespace ost
136 
137 #endif
138 
139 #endif
A copy-on-write string class that operates by reference count.
Definition: string.h:82
Definition: address.h:58
A sub-hierarchy for all task synchronizion related exceptions.
Definition: exception.h:123
Common C++ generic string class.
Mainline exception handler, this is the root for all Common C++ exceptions and assures the ansi C++ e...
Definition: exception.h:73
A sub-hierarchy for thread exceptions.
Definition: exception.h:111
A sub-hierarchy for all Common C++ I/O related classes.
Definition: exception.h:91