X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Utils%2FException.cc;h=e23357f23f95f24bfe4b4c9a083f34c126313269;hb=15ac5ae4166db4387b4a219b7c42f7fc5a9681a6;hp=2185643af484d5f174d63f10fabbdc0ccd1ec11c;hpb=34378cabd0ef59515f60b8e535d50fd5488c84e2;p=senf.git diff --git a/Utils/Exception.cc b/Utils/Exception.cc index 2185643..e23357f 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 +// 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 @@ -27,40 +27,31 @@ //#include "Exception.ih" // Custom includes -#include -#include #define prefix_ ///////////////////////////////cc.p//////////////////////////////////////// -prefix_ void senf::throwErrno(std::string const & where, int code) -{ - switch (code) { - - // BOOST_PP_REPEAT is limited to 256 repetitions. The max errno value I found in any header file - // was somewhere around 530 or so. I assume going to 1024 will be good enough. This explicit - // code will be optimized into a jump table by g++ (which is more efficient than trying to do - // the table oneself) - -# define ExceptionCase(z, n, data) case n: throw ErrnoException(where); - BOOST_PP_REPEAT(256, ExceptionCase, _) ; -# undef ExceptionCase +/////////////////////////////////////////////////////////////////////////// +// senf::Exception -# define ExceptionCase(z, n, data) case 256+n: throw ErrnoException<256+n>(where); - BOOST_PP_REPEAT(256, ExceptionCase, _) ; -# undef ExceptionCase +prefix_ senf::Exception::~Exception() + throw() +{} -# define ExceptionCase(z, n, data) case 512+n: throw ErrnoException<512+n>(where); - BOOST_PP_REPEAT(256, ExceptionCase, _) ; -# undef ExceptionCase +prefix_ char const * senf::Exception::what() + const throw() +{ + return message_.c_str(); +} -# define ExceptionCase(z, n, data) case 768+n: throw ErrnoException<768+n>(where); - BOOST_PP_REPEAT(256, ExceptionCase, _) ; -# undef ExceptionCase +/////////////////////////////////////////////////////////////////////////// +// senf::SystemException - default: - throw SystemException(where, code); - } +prefix_ void senf::SystemException::init(std::string const & descr, int code) +{ + code_ = code; + (*this) << "[" << errorString() << "]"; + if (! descr.empty()) (*this) << " " << descr; } ///////////////////////////////cc.e////////////////////////////////////////