4 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
5 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
6 // Stefan Bund <stefan.bund@fokus.fraunhofer.de>
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 \brief Exception public header */
27 #define HH_Exception_ 1
32 #include <boost/preprocessor/repeat.hpp>
33 #include <boost/preprocessor/cat.hpp>
35 //#include "Exception.mpp"
36 ///////////////////////////////hh.p////////////////////////////////////////
40 /** \brief Exception handling standard UNIX errors (errno)
42 This exception is thrown to signal generic errno failures.
44 \todo make where and err accessors and make the member variables private
46 \idea Add a template class derived from SystemException which takes the error number as a
47 numeric argument. This allows catching specific errno conditions: ErrnoException<EPIPE> etc.
49 \idea Add a generic error thrower which takes the origin string and errno value as an
50 argument and will throw a corresponding template class instance. This would just be a big
51 switch statement containing all possible errno values, probably created using some macro
54 class SystemException : public std::exception
57 SystemException(); ///< SystemException without error location infor
58 /**< The error code is taken from the current value of the
59 global 'errno' variable */
61 explicit SystemException(int code); ///< SystemException without error location info
62 /**< \param[in] code error number (the errno value) */
64 explicit SystemException(char const * where); ///< SystemException with error location info
65 /**< The error code is taken from the current value of the
66 global 'errno' variable
67 \param[in] where description of error origin */
69 SystemException(char const * where, int code); ///< SystemException with error location info
70 /**< \param[in] where description of error origin
71 \param[in] code error number (the errno value) */
73 virtual char const * what() const throw(); ///< Return verbose error description
75 char const * where() const; ///< Error origin
76 int code() const; ///< Error code (errno number)
77 char const * description() const; ///< Error description (strerror() value)
79 bool anyOf(int c0, int c1=0, int c2=0, int c3=0, int c4=0, int c5=0,
80 int c6=0, int c7=0, int c8=0, int c9=0);
82 virtual ~SystemException() throw();
87 char const * const where_;
93 class ErrnoException : public SystemException
96 static int const fixed_code = Code;
99 explicit ErrnoException(char const * where);
103 void throwErrno(char const * where);
104 void throwErrno(int code);
105 void throwErrno(char const * where, int code);
107 enum NoThrow_t { nothrow };
111 ///////////////////////////////hh.e////////////////////////////////////////
112 #include "Exception.cci"
113 //#include "Exception.ct"
114 #include "Exception.cti"
121 // c-file-style: "senf"
122 // indent-tabs-mode: nil
123 // ispell-local-dictionary: "american"
124 // compile-command: "scons -u test"
125 // comment-column: 40