From: wolf Date: Tue, 17 Dec 2002 17:04:57 +0000 (+0000) Subject: If we promise we don't throw an exception in a function, then make X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9a3f121c832233eadc53b45be85b192fc5efdba3;p=dealii-svn.git If we promise we don't throw an exception in a function, then make pretty damn sure we don't. git-svn-id: https://svn.dealii.org/trunk@6843 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/base/source/exceptions.cc b/deal.II/base/source/exceptions.cc index afd76e9ea6..80e1914a7b 100644 --- a/deal.II/base/source/exceptions.cc +++ b/deal.II/base/source/exceptions.cc @@ -82,42 +82,70 @@ void ExceptionBase::PrintInfo (std::ostream &out) const const char * ExceptionBase::what () const throw () { - // have a place where to store the - // description of the exception as a char * - // - // this thing obviously is not multi-threading - // safe, but we don't care about that for now - // - // we need to make this object static, since - // we want to return the data stored in it - // and therefore need a liftime which is - // longer than the execution time of this - // function - static std::string description; - // convert the messages printed by the - // exceptions into a std::string + // if we say that this function + // does not throw exceptions, we + // better make sure it does not + try + { + // have a place where to store the + // description of the exception as + // a char * + // + // this thing obviously is not + // multi-threading safe, but we + // don't care about that for now + // + // we need to make this object + // static, since we want to return + // the data stored in it and + // therefore need a lifetime which + // is longer than the execution + // time of this function + static std::string description; + // convert the messages printed by + // the exceptions into a + // std::string #ifdef HAVE_STD_STRINGSTREAM - std::ostringstream converter; + std::ostringstream converter; #else - std::ostrstream converter; + std::ostrstream converter; #endif - converter << "--------------------------------------------------------" - << std::endl; - // put general info into the std::string - PrintExcData (converter); - // put in exception specific data - PrintInfo (converter); + converter << "--------------------------------------------------------" + << std::endl; + // put general info into the std::string + PrintExcData (converter); + // put in exception specific data + PrintInfo (converter); - converter << "--------------------------------------------------------" - << std::endl; + converter << "--------------------------------------------------------" + << std::endl; #ifndef HAVE_STD_STRINGSTREAM - converter << std::ends; + converter << std::ends; #endif - description = converter.str(); + description = converter.str(); - return description.c_str(); + return description.c_str(); + } + catch (std::exception &exc) + { + std::cerr << "*** Exception encountered in exception handling routines ***" + << std::endl + << "*** Message is " << std::endl + << exc.what () << std::endl + << "*** Aborting! ***" << std::endl; + std::abort (); + return 0; + } + catch (...) + { + std::cerr << "*** Exception encountered in exception handling routines ***" + << std::endl + << "*** Aborting! ***" << std::endl; + std::abort (); + return 0; + } };