CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/FWCore/Utilities/src/EDMException.cc

Go to the documentation of this file.
00001 
00002 #include "FWCore/Utilities/interface/EDMException.h"
00003 
00004 namespace edm {
00005   namespace errors {
00006     struct FilledMap {
00007       FilledMap();
00008       Exception::CodeMap trans_;
00009     };
00010     FilledMap::FilledMap() : trans_() {
00011       EDM_MAP_ENTRY_NONS(trans_, CommandLineProcessing);
00012       EDM_MAP_ENTRY_NONS(trans_, ConfigFileNotFound);
00013       EDM_MAP_ENTRY_NONS(trans_, ConfigFileReadError);
00014       EDM_MAP_ENTRY_NONS(trans_, OtherCMS);
00015       EDM_MAP_ENTRY_NONS(trans_, StdException);
00016       EDM_MAP_ENTRY_NONS(trans_, Unknown);
00017       EDM_MAP_ENTRY_NONS(trans_, BadAlloc);
00018       EDM_MAP_ENTRY_NONS(trans_, BadExceptionType);
00019       EDM_MAP_ENTRY_NONS(trans_, ProductNotFound);
00020       EDM_MAP_ENTRY_NONS(trans_, DictionaryNotFound);
00021       EDM_MAP_ENTRY_NONS(trans_, NoProductSpecified);
00022       EDM_MAP_ENTRY_NONS(trans_, InsertFailure);
00023       EDM_MAP_ENTRY_NONS(trans_, Configuration);
00024       EDM_MAP_ENTRY_NONS(trans_, LogicError);
00025       EDM_MAP_ENTRY_NONS(trans_, UnimplementedFeature);
00026       EDM_MAP_ENTRY_NONS(trans_, InvalidReference);
00027       EDM_MAP_ENTRY_NONS(trans_, NullPointerError);
00028       EDM_MAP_ENTRY_NONS(trans_, EventTimeout);
00029       EDM_MAP_ENTRY_NONS(trans_, EventCorruption);
00030       EDM_MAP_ENTRY_NONS(trans_, ScheduleExecutionFailure);
00031       EDM_MAP_ENTRY_NONS(trans_, EventProcessorFailure);
00032       EDM_MAP_ENTRY_NONS(trans_, FileInPathError);
00033       EDM_MAP_ENTRY_NONS(trans_, FileOpenError);
00034       EDM_MAP_ENTRY_NONS(trans_, FileReadError);
00035       EDM_MAP_ENTRY_NONS(trans_, FatalRootError);
00036       EDM_MAP_ENTRY_NONS(trans_, MismatchedInputFiles);
00037       EDM_MAP_ENTRY_NONS(trans_, ProductDoesNotSupportViews);
00038       EDM_MAP_ENTRY_NONS(trans_, ProductDoesNotSupportPtr);
00039       EDM_MAP_ENTRY_NONS(trans_, NotFound);
00040       EDM_MAP_ENTRY_NONS(trans_, FormatIncompatibility);
00041     }
00042   }
00043 
00044   void getCodeTable(Exception::CodeMap*& setme) {
00045     static errors::FilledMap fm;
00046     setme = &fm.trans_;
00047   }
00048 
00050 
00051   std::string Exception::codeToString(errors::ErrorCodes c) {
00052     extern void getCodeTable(CodeMap*&);
00053     CodeMap* trans;
00054     getCodeTable(trans);
00055     CodeMap::const_iterator i(trans->find(c));
00056     return i!=trans->end() ? i->second : std::string("UnknownCode");
00057   }
00058 
00059   Exception::Exception(errors::ErrorCodes aCategory):
00060     cms::Exception(codeToString(aCategory)),
00061     category_(aCategory) {
00062   }
00063 
00064   Exception::Exception(errors::ErrorCodes aCategory, std::string const& message):
00065     cms::Exception(codeToString(aCategory),message),
00066     category_(aCategory) {
00067   }
00068 
00069   Exception::Exception(errors::ErrorCodes aCategory, char const* message):
00070     cms::Exception(codeToString(aCategory), std::string(message)),
00071     category_(aCategory) {
00072   }
00073 
00074   Exception::Exception(errors::ErrorCodes aCategory, std::string const& message, cms::Exception const& another):
00075     cms::Exception(codeToString(aCategory),message,another),
00076     category_(aCategory) {
00077   }
00078 
00079   Exception::Exception(errors::ErrorCodes aCategory, char const* message, cms::Exception const& another):
00080     cms::Exception(codeToString(aCategory), std::string(message), another),
00081     category_(aCategory) {
00082   }
00083 
00084   Exception::Exception(Exception const& other):
00085     cms::Exception(other),
00086     category_(other.category_) {
00087   }
00088 
00089   Exception::~Exception() throw() {
00090   }
00091 
00092   int
00093   Exception::returnCode_() const {
00094     return static_cast<int>(category_);
00095   }
00096 
00097   void
00098   Exception::throwThis(errors::ErrorCodes aCategory,
00099                        char const* message0,
00100                        char const* message1,
00101                        char const* message2,
00102                        char const* message3,
00103                        char const* message4) {
00104     Exception e(aCategory, std::string(message0));
00105     e << message1 << message2 << message3 << message4;
00106     throw e;
00107   }
00108 
00109   void
00110   Exception::throwThis(errors::ErrorCodes aCategory, char const* message0, int intVal, char const* message1) {
00111     Exception e(aCategory, std::string(message0));
00112     e << intVal << message1;
00113     throw e;
00114   }
00115 
00116   Exception* Exception::clone() const {
00117     return new Exception(*this);
00118   }
00119 
00120   void
00121   Exception::rethrow() {
00122     throw *this;
00123   }
00124 }