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