00001 #ifndef FWCore_Framework_MakeDataException_h 00002 #define FWCore_Framework_MakeDataException_h 00003 // -*- C++ -*- 00004 // 00005 // Package: Framework 00006 // Class : MakeDataException 00007 // 00029 // 00030 // Author: Chris Jones 00031 // Created: Fri Apr 1 13:18:53 EST 2005 00032 // $Id: MakeDataException.h,v 1.7 2007/06/14 17:52:15 wmtan Exp $ 00033 // 00034 00035 // system include files 00036 #include <string> 00037 00038 // user include files 00039 #include "FWCore/Framework/interface/HCTypeTagTemplate.h" 00040 #include "FWCore/Framework/interface/DataKey.h" 00041 #include "FWCore/Framework/interface/EventSetupRecordKey.h" 00042 #include "FWCore/Utilities/interface/Exception.h" 00043 00044 // forward declarations 00045 namespace edm { 00046 namespace eventsetup { 00047 template< class RecordT, class DataT> 00048 class MakeDataException : public cms::Exception 00049 { 00050 00051 public: 00052 MakeDataException(const DataKey& iKey) : 00053 cms::Exception("MakeDataException"), 00054 message_(standardMessage(iKey)) 00055 { 00056 this->append(myMessage()); 00057 } 00058 00059 MakeDataException(const std::string& iAdditionalInfo, 00060 const DataKey& iKey) : 00061 message_(messageWithInfo(iKey, iAdditionalInfo)) 00062 { 00063 this->append(this->myMessage()); 00064 } 00065 00066 ~MakeDataException() throw() {} 00067 00068 // ---------- const member functions --------------------- 00069 const char* myMessage() const throw() { 00070 return message_.c_str(); 00071 } 00072 00073 // ---------- static member functions -------------------- 00074 static std::string standardMessage(const DataKey& iKey) { 00075 std::string returnValue = std::string("Error while making data ") 00076 +"\"" 00077 +heterocontainer::HCTypeTagTemplate<DataT,DataKey>::className() 00078 +"\" " 00079 +"\"" 00080 +iKey.name().value() 00081 +"\" " 00082 +"in Record " 00083 +heterocontainer::HCTypeTagTemplate<RecordT, EventSetupRecordKey>::className(); 00084 return returnValue; 00085 } 00086 00087 static std::string messageWithInfo(const DataKey& iKey, 00088 const std::string& iInfo) { 00089 return standardMessage(iKey) +"\n"+iInfo; 00090 } 00091 // ---------- member functions --------------------------- 00092 00093 private: 00094 //MakeDataException(const MakeDataException&); // stop default 00095 00096 //const MakeDataException& operator=(const MakeDataException&); // stop default 00097 00098 // ---------- member data -------------------------------- 00099 std::string message_; 00100 00101 }; 00102 00103 } 00104 } 00105 #endif