X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Utils%2FException.cc;h=4c74f6cda185694ee17aed1976af5e381748e600;hb=d2459b6c8249291588fd3d0d125ed3d38e003b55;hp=a5349100137cb5434ff65ec61c6565953b3bbd3c;hpb=c52cd7d87dbb525c1267aad27391b8b7365dbb57;p=senf.git diff --git a/Utils/Exception.cc b/Utils/Exception.cc index a534910..4c74f6c 100644 --- a/Utils/Exception.cc +++ b/Utils/Exception.cc @@ -1,9 +1,9 @@ // $Id$ // -// Copyright (C) 2006 -// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) -// Kompetenzzentrum fuer Satelitenkommunikation (SatCom) -// Stefan Bund +// Copyright (C) 2006 +// Fraunhofer Institute for Open Communication Systems (FOKUS) +// Competence Center NETwork research (NET), St. Augustin, GERMANY +// Stefan Bund // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -20,21 +20,82 @@ // Free Software Foundation, Inc., // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// Definition of non-inline non-template functions +/** \file + \brief Exception non-inline non-template implementation */ #include "Exception.hh" //#include "Exception.ih" // Custom includes -#include +#include +#include +#include "../config.hh" +#include "impl/demangle.h" #define prefix_ ///////////////////////////////cc.p//////////////////////////////////////// -prefix_ char const * satcom::lib::SystemException::what() +/////////////////////////////////////////////////////////////////////////// +// senf::Exception + +#ifdef SENF_DEBUG +prefix_ void senf::ExceptionMixin::addBacktrace() +{ + void * entries[SENF_DEBUG_BACKTRACE_NUMCALLERS]; + unsigned nEntries( ::backtrace(entries, SENF_DEBUG_BACKTRACE_NUMCALLERS) ); + char ** symbols = ::backtrace_symbols(entries, nEntries); + + std::stringstream ss; + ss << "\nException at\n"; + for (unsigned i=0; ierr); + return message().c_str(); +} + +/////////////////////////////////////////////////////////////////////////// +// senf::SystemException + +prefix_ void senf::SystemException::init(std::string const & descr, int code + _SENF_EXC_DEBUG_ARGS_ND) +{ + code_ = code; +# ifdef SENF_DEBUG + if (file && line) + (*this) << "Exception at " << file << ":" << line << "\n"; +# endif + (*this) << "[" << errorString() << "]"; + if (! descr.empty()) (*this) << " " << descr; } ///////////////////////////////cc.e//////////////////////////////////////// @@ -43,5 +104,10 @@ prefix_ char const * satcom::lib::SystemException::what() // Local Variables: // mode: c++ -// c-file-style: "satcom" +// fill-column: 100 +// c-file-style: "senf" +// indent-tabs-mode: nil +// ispell-local-dictionary: "american" +// compile-command: "scons -u test" +// comment-column: 40 // End: