Search:

SENF Extensible Network Framework

  • Home
  • Download
  • Wiki
  • BerliOS
  • ChangeLog
  • Browse SVN
  • Bug Tracker
  • Overview
  • Examples
  • HowTos
  • Glossary
  • PPI
  • Packets
  • Scheduler
  • Socket
  • Utils
  • Console
  • Daemon
  • Logger
  • Termlib
  • Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

Exception.cci

Go to the documentation of this file.
00001 // $Id: Exception.cci 1779 2011-04-07 12:35:05Z jmo $
00002 //
00003 // Copyright (C) 2006 Stefan Bund <g0dil@senf.berlios.de>
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
00017 // Free Software Foundation, Inc.,
00018 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00019 
00023 // Custom includes
00024 #include <errno.h>
00025 #include <cstring>
00026 
00027 #define prefix_ inline
00028 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00029 
00030 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00031 // senf::ExceptionMixin
00032 
00033 prefix_ senf::ExceptionMixin::ExceptionMixin(std::string const & description)
00034     : what_(description)
00035 {
00036 #ifdef SENF_BACKTRACE
00037     addBacktrace();
00038 #endif
00039 }
00040 
00041 prefix_ std::string senf::ExceptionMixin::message()
00042     const
00043 {
00044 #ifdef SENF_DEBUG
00045     return what_.substr(excLen_);
00046 #else
00047     return what_;
00048 #endif
00049 }
00050 
00051 prefix_ std::string senf::ExceptionMixin::backtrace()
00052     const
00053 {
00054 #ifdef SENF_DEBUG
00055     return what_.substr(0,excLen_-4);
00056 #else
00057     return "";
00058 #endif
00059 }
00060 
00061 prefix_ void senf::ExceptionMixin::append(std::string text)
00062 {
00063     what_ += text;
00064 }
00065 
00066 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00067 // senf::Exception
00068 
00069 prefix_ senf::Exception::Exception(std::string const & description)
00070     : ExceptionMixin(description)
00071 {}
00072 
00073 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00074 // senf::SystemException
00075 
00076 prefix_ senf::SystemException::SystemException(std::string const & descr _SENF_EXC_DEBUG_ARGS_ND)
00077 {
00078     init(descr, errno _SENF_EXC_DEBUG_ARGS_P);
00079 }
00080 
00081 prefix_ senf::SystemException::SystemException(int code _SENF_EXC_DEBUG_ARGS_ND)
00082 {
00083     init("", code _SENF_EXC_DEBUG_ARGS_P);
00084 }
00085 
00086 prefix_ senf::SystemException::SystemException(std::string const & descr, int code
00087                                                _SENF_EXC_DEBUG_ARGS_ND)
00088 {
00089     init(descr, code _SENF_EXC_DEBUG_ARGS_P);
00090 }
00091 
00092 prefix_ int senf::SystemException::errorNumber()
00093     const
00094 {
00095     return code_;
00096 }
00097 
00098 prefix_ char const * senf::SystemException::errorString()
00099     const
00100 {
00101     return std::strerror(code_);
00102 }
00103 
00104 prefix_ bool senf::SystemException::anyOf(int c0, int c1, int c2, int c3, int c4, int c5,
00105                                           int c6, int c7, int c8, int c9)
00106     const
00107 {
00108     return
00109         (c0 && code_ == c0) ||
00110         (c1 && code_ == c1) ||
00111         (c2 && code_ == c2) ||
00112         (c3 && code_ == c3) ||
00113         (c4 && code_ == c4) ||
00114         (c5 && code_ == c5) ||
00115         (c6 && code_ == c6) ||
00116         (c7 && code_ == c7) ||
00117         (c8 && code_ == c8) ||
00118         (c9 && code_ == c9);
00119 }
00120 
00121 prefix_  senf::SystemException::~SystemException()
00122     throw()
00123 {}
00124 
00125 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00126 #undef prefix_
00127 
00128 
00129 // Local Variables:
00130 // mode: c++
00131 // fill-column: 100
00132 // c-file-style: "senf"
00133 // indent-tabs-mode: nil
00134 // ispell-local-dictionary: "american"
00135 // compile-command: "scons -u test"
00136 // comment-column: 40
00137 // End:

Contact: senf-dev@lists.berlios.de | © 2006-2010 Fraunhofer Institute for Open Communication Systems, Network Research