CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/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       EDM_MAP_ENTRY_NONS(trans_, FallbackFileOpenError);
00042       EDM_MAP_ENTRY_NONS(trans_, ExceededResourceVSize);
00043       EDM_MAP_ENTRY_NONS(trans_, ExceededResourceRSS);
00044       EDM_MAP_ENTRY_NONS(trans_, ExceededResourceTime);
00045     }
00046   }
00047 
00048   void getCodeTable(Exception::CodeMap*& setme) {
00049     static errors::FilledMap fm;
00050     setme = &fm.trans_;
00051   }
00052 
00054 
00055   std::string Exception::codeToString(errors::ErrorCodes c) {
00056     extern void getCodeTable(CodeMap*&);
00057     CodeMap* trans;
00058     getCodeTable(trans);
00059     CodeMap::const_iterator i(trans->find(c));
00060     return i!=trans->end() ? i->second : std::string("UnknownCode");
00061   }
00062 
00063   Exception::Exception(errors::ErrorCodes aCategory):
00064     cms::Exception(codeToString(aCategory)),
00065     category_(aCategory) {
00066   }
00067 
00068   Exception::Exception(errors::ErrorCodes aCategory, std::string const& message):
00069     cms::Exception(codeToString(aCategory),message),
00070     category_(aCategory) {
00071   }
00072 
00073   Exception::Exception(errors::ErrorCodes aCategory, char const* message):
00074     cms::Exception(codeToString(aCategory), std::string(message)),
00075     category_(aCategory) {
00076   }
00077 
00078   Exception::Exception(errors::ErrorCodes aCategory, std::string const& message, cms::Exception const& another):
00079     cms::Exception(codeToString(aCategory),message,another),
00080     category_(aCategory) {
00081   }
00082 
00083   Exception::Exception(errors::ErrorCodes aCategory, char const* message, cms::Exception const& another):
00084     cms::Exception(codeToString(aCategory), std::string(message), another),
00085     category_(aCategory) {
00086   }
00087 
00088   Exception::Exception(Exception const& other):
00089     cms::Exception(other),
00090     category_(other.category_) {
00091   }
00092 
00093   Exception::~Exception() throw() {
00094   }
00095 
00096   Exception&
00097   Exception::operator=(Exception const& other) {
00098     Exception temp(other);
00099     this->swap(temp);
00100     return *this;
00101   }
00102   
00103   int
00104   Exception::returnCode_() const {
00105     return static_cast<int>(category_);
00106   }
00107 
00108   void
00109   Exception::throwThis(errors::ErrorCodes aCategory,
00110                        char const* message0,
00111                        char const* message1,
00112                        char const* message2,
00113                        char const* message3,
00114                        char const* message4) {
00115     Exception e(aCategory, std::string(message0));
00116     e << message1 << message2 << message3 << message4;
00117     throw e;
00118   }
00119 
00120   void
00121   Exception::throwThis(errors::ErrorCodes aCategory, char const* message0, int intVal, char const* message1) {
00122     Exception e(aCategory, std::string(message0));
00123     e << intVal << message1;
00124     throw e;
00125   }
00126 
00127   Exception* Exception::clone() const {
00128     return new Exception(*this);
00129   }
00130 
00131   void
00132   Exception::rethrow() {
00133     throw *this;
00134   }
00135 }