CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/Utilities/General/src/CMSexception.cc

Go to the documentation of this file.
00001 #include "Utilities/General/interface/CMSexception.h"
00002 #include "Utilities/General/interface/UncatchedException.h"
00003 #include "Utilities/General/interface/ioutils.h"
00004 
00005 LockMutex::Mutex UncatchedException::mutex;
00006 int UncatchedException::count_=0; 
00007 cms::Exception * UncatchedException::it=0;
00008 
00009 UncatchedException::UncatchedException() {
00010   LockMutex a(mutex);
00011   count_++;
00012 }
00013 
00014 UncatchedException::UncatchedException(const cms::Exception & err) {
00015   LockMutex a(mutex);
00016   count_++;
00017   //this is bad but needed in order to make transition
00018   it = new cms::Exception(err);
00019 }
00020 
00021 void UncatchedException::dump(std::ostream & o, bool det) {
00022   if (!it) return;
00023   Genexception * exp = dynamic_cast<Genexception*>(it);
00024   if (exp) exp->dump(o,det);
00025   else o << it->what() << std::endl;
00026 }
00027 
00028 void UncatchedException::rethrow() {
00029   if (count()==0) return;
00030   std::string mess("found "); mess+=toa()(count());
00031   mess+= " uncaught exceptions";
00032   if (!it) throw Genexception(mess);
00033 
00034   //bad but needed in order to make transition to standard CMS exceptions
00035   throw *it;
00036   //it->rethrow();
00037   
00038 }
00039 
00040 int UncatchedException::count() {
00041   LockMutex a(mutex);
00042   return count_;
00043 }
00044 
00045 //-------------------------------------------------------------------
00046 
00047 BaseGenexception::BaseGenexception() throw() {}
00048 
00049 
00050 BaseGenexception::BaseGenexception(const std::string & mess) throw() : 
00051   message(mess) {}
00052 
00053 BaseGenexception::~BaseGenexception() throw() {
00054   /* cout << "deleting a BaseGenexception " << message << " at " << this << endl; */
00055 }
00056 
00057 //-------------------------------------------------------------------
00058 
00059 Genexception::Genexception() throw() {traceit();}
00060 
00061 
00062 Genexception::Genexception(const std::string & mess) throw() : 
00063   BaseGenexception(mess) {
00064   traceit();
00065 }
00066 
00067 
00068 Genexception::~Genexception() throw() {}
00069 
00070 void Genexception::add(Genexception * in) throw() {
00071   if (in==0) return;
00072   // push in the stack...
00073   if (next.get()) (*next).add(in);
00074   else next = own_ptr<Genexception>(in);
00075 }
00076 
00077 #include<iostream>
00078 void Genexception::dump(std::ostream & o, bool it)  const throw() {
00079   if (next.get()) {
00080     (*next).dump(o,it);
00081     o << "Generated by: " ;
00082   }
00083   o << what() << "\n" << std::endl;
00084   if(it) o << trace()<< std::endl;
00085 }
00086 
00087 #include "Utilities/General/interface/BackTrace.h"
00088 #include<sstream>
00089 
00090 void Genexception::traceit() throw() {
00091   std::ostringstream oss;
00092 
00093   BackTrace a;
00094   a.trace(oss);
00095   trace_ = oss.str();
00096 }
00097 
00098 namespace Capri {
00099   namespace details {
00100     static std::string from(" from ");
00101   }
00102 }
00103 
00104 Capri::Error::Error(const std::string & level, const std::string & mess) throw() :
00105   Genexception(level+details::from+mess) {}
00106 
00107 
00108 GenTerminate::GenTerminate() throw() {}
00109 GenTerminate::GenTerminate(const std::string & mess) throw() : Genexception(mess) {}
00110 GenTerminate::~GenTerminate() throw() {}
00111 
00112 
00113 Success::Success(){}
00114 Success::~Success(){}