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.cc

Go to the documentation of this file.
00001 // $Id: Exception.cc 1790 2011-06-06 16:32:21Z tho $
00002 //
00003 // Copyright (C) 2006
00004 // Fraunhofer (FOKUS)
00005 // Competence Center NETwork research (NET), St. Augustin, GERMANY
00006 //     Stefan Bund <g0dil@berlios.de>
00007 //
00008 // This program is free software; you can redistribute it and/or modify
00009 // it under the terms of the GNU General Public License as published by
00010 // the Free Software Foundation; either version 2 of the License, or
00011 // (at your option) any later version.
00012 //
00013 // This program is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 // GNU General Public License for more details.
00017 //
00018 // You should have received a copy of the GNU General Public License
00019 // along with this program; if not, write to the
00020 // Free Software Foundation, Inc.,
00021 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00022 
00026 #include "Exception.hh"
00027 //#include "Exception.ih"
00028 
00029 // Custom includes
00030 #ifdef SENF_BACKTRACE
00031    #include <execinfo.h>
00032 #endif
00033 #include <sstream>
00034 #include "Backtrace.hh"
00035 
00036 #define prefix_
00037 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00038 
00039 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00040 // senf::Exception
00041 
00042 #ifdef SENF_BACKTRACE
00043 prefix_ void senf::ExceptionMixin::addBacktrace()
00044 {
00045     void * entries[SENF_DEBUG_BACKTRACE_NUMCALLERS];
00046     int nEntries (::backtrace(entries, SENF_DEBUG_BACKTRACE_NUMCALLERS));
00047 
00048     std::stringstream ss;
00049     ss << "\nException at\n";
00050     formatBacktrace(ss, entries, nEntries);
00051     ss << "-- \n";
00052     excLen_ = ss.str().size();
00053     ss << what_;
00054     what_ = ss.str();
00055 }
00056 #endif
00057 
00058 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00059 // senf::Exception
00060 
00061 prefix_ senf::Exception::~Exception()
00062     throw()
00063 {}
00064 
00065 prefix_ char const * senf::Exception::what()
00066     const throw()
00067 {
00068     return what_.c_str();
00069 }
00070 
00071 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00072 // senf::SystemException
00073 
00074 prefix_ void senf::SystemException::init(std::string const & descr, int code
00075                                          _SENF_EXC_DEBUG_ARGS_ND)
00076 {
00077     code_ = code;
00078 #   ifdef SENF_DEBUG
00079     if (file && line)
00080         (*this) << "Exception at " << file << ":" << line << "\n";
00081 #   endif
00082     (*this) << "[" << errorString() << "]";
00083     if (! descr.empty()) (*this) << " " << descr;
00084 }
00085 
00086 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00087 #undef prefix_
00088 
00089 
00090 // Local Variables:
00091 // mode: c++
00092 // fill-column: 100
00093 // c-file-style: "senf"
00094 // indent-tabs-mode: nil
00095 // ispell-local-dictionary: "american"
00096 // compile-command: "scons -u test"
00097 // comment-column: 40
00098 // End:

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