00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "DataFormats/FWLite/interface/ErrorThrower.h"
00018 #include "FWCore/Utilities/interface/EDMException.h"
00019 #include "FWCore/Utilities/interface/TypeID.h"
00020
00021 using namespace fwlite;
00022
00023
00024
00025 namespace {
00026 class NoProductErrorThrower : public ErrorThrower {
00027 public:
00028 NoProductErrorThrower(const std::type_info& iType, const char*iModule, const char*iInstance, const char*iProcess):
00029 type_(&iType), module_(iModule), instance_(iInstance), process_(iProcess) {}
00030
00031 void throwIt() const {
00032
00033 edm::TypeID type(*type_);
00034 throw edm::Exception(edm::errors::ProductNotFound)<<"A branch was found for \n type ='"<<type.className()<<"'\n module='"<<module_
00035 <<"'\n productInstance='"<<((0!=instance_)?instance_:"")<<"'\n process='"<<((0!=process_)?process_:"")<<"'\n"
00036 "but no data is available for this Event";
00037 }
00038 virtual ErrorThrower* clone() const {
00039 return new NoProductErrorThrower(*this);
00040 }
00041
00042 private:
00043 const std::type_info* type_;
00044 const char* module_;
00045 const char* instance_;
00046 const char* process_;
00047 };
00048
00049 class NoBranchErrorThrower : public ErrorThrower {
00050 public:
00051 NoBranchErrorThrower(const std::type_info& iType, const char*iModule, const char*iInstance, const char*iProcess):
00052 type_(&iType), module_(iModule), instance_(iInstance), process_(iProcess) {}
00053
00054 void throwIt() const {
00055
00056 edm::TypeID type(*type_);
00057 throw edm::Exception(edm::errors::ProductNotFound)<<"No branch was found for \n type ='"<<type.className()<<"'\n module='"<<module_
00058 <<"'\n productInstance='"<<((0!=instance_)?instance_:"")<<"'\n process='"<<((0!=process_)?process_:"")<<"'";
00059 }
00060
00061 virtual ErrorThrower* clone() const {
00062 return new NoBranchErrorThrower(*this);
00063 }
00064
00065 private:
00066 const std::type_info* type_;
00067 const char* module_;
00068 const char* instance_;
00069 const char* process_;
00070 };
00071
00072 class UnsetErrorThrower : public ErrorThrower {
00073 void throwIt() const {
00074 throw cms::Exception("UnsetHandle")<<"The fwlite::Handle was never set";
00075 }
00076
00077 virtual ErrorThrower* clone() const {
00078 return new UnsetErrorThrower(*this);
00079 }
00080
00081 };
00082 }
00083
00084
00085
00086
00087
00088
00089
00090 ErrorThrower::ErrorThrower()
00091 {
00092 }
00093
00094
00095
00096
00097
00098
00099 ErrorThrower::~ErrorThrower()
00100 {
00101 }
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126 ErrorThrower*
00127 ErrorThrower::unsetErrorThrower() {
00128 return new UnsetErrorThrower();
00129 }
00130
00131 ErrorThrower*
00132 ErrorThrower::errorThrowerBranchNotFoundException(const std::type_info& iType, const char* iModule, const char* iInstance, const char* iProcess){
00133 return new NoBranchErrorThrower(iType,iModule,iInstance,iProcess);
00134 }
00135
00136 ErrorThrower*
00137 ErrorThrower::errorThrowerProductNotFoundException(const std::type_info& iType, const char* iModule, const char* iInstance, const char* iProcess){
00138 return new NoProductErrorThrower(iType,iModule,iInstance,iProcess);
00139 }