X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Utils%2FException.cc;h=28073e67e91a3704fdc941959adfda32676fc620;hb=29825d5db542bd3a6769101abe40a8ed86409613;hp=8b2f2802c6e88020f79a9469ffa284fd0516b9e3;hpb=63b650afb727cce067817ce9451eecb932446bf3;p=senf.git diff --git a/Utils/Exception.cc b/Utils/Exception.cc index 8b2f280..28073e6 100644 --- a/Utils/Exception.cc +++ b/Utils/Exception.cc @@ -1,8 +1,8 @@ // $Id$ // // Copyright (C) 2006 -// Fraunhofer Institute for Open Communication Systems (FOKUS) -// Competence Center NETwork research (NET), St. Augustin, GERMANY +// 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 @@ -31,38 +31,28 @@ #define prefix_ ///////////////////////////////cc.p//////////////////////////////////////// -prefix_ void senf::throwErrno(std::string const & where, int code) -{ -#ifndef SENF_NO_ERRNOEXC - 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); - } -#else - throw SystemException(where, code); -#endif +prefix_ void senf::SystemException::init(std::string const & where, int code) +{ + code_ = code; + if (! where.empty()) + (*this) << where << ": "; + (*this) << "(" << code << ") " << description(); } ///////////////////////////////cc.e////////////////////////////////////////