Go to the documentation of this file.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 #include <ostream>
00021
00022 using namespace fwlite;
00023
00024
00025
00026 namespace {
00027 class NoProductErrorThrower : public ErrorThrower {
00028 public:
00029 NoProductErrorThrower(const std::type_info& iType, const char*iModule, const char*iInstance, const char*iProcess):
00030 type_(&iType), module_(iModule), instance_(iInstance), process_(iProcess) {}
00031
00032 void throwIt() const {
00033
00034 edm::TypeID type(*type_);
00035 throw edm::Exception(edm::errors::ProductNotFound)<<"A branch was found for \n type ='"<<type.className()<<"'\n module='"<<module_
00036 <<"'\n productInstance='"<<((0!=instance_)?instance_:"")<<"'\n process='"<<((0!=process_)?process_:"")<<"'\n"
00037 "but no data is available for this Event";
00038 }
00039 virtual ErrorThrower* clone() const {
00040 return new NoProductErrorThrower(*this);
00041 }
00042
00043 private:
00044 const std::type_info* type_;
00045 const char* module_;
00046 const char* instance_;
00047 const char* process_;
00048 };
00049
00050 class NoBranchErrorThrower : public ErrorThrower {
00051 public:
00052 NoBranchErrorThrower(const std::type_info& iType, const char*iModule, const char*iInstance, const char*iProcess):
00053 type_(&iType), module_(iModule), instance_(iInstance), process_(iProcess) {}
00054
00055 void throwIt() const {
00056
00057 edm::TypeID type(*type_);
00058 throw edm::Exception(edm::errors::ProductNotFound)<<"No branch was found for \n type ='"<<type.className()<<"'\n module='"<<module_
00059 <<"'\n productInstance='"<<((0!=instance_)?instance_:"")<<"'\n process='"<<((0!=process_)?process_:"")<<"'";
00060 }
00061
00062 virtual ErrorThrower* clone() const {
00063 return new NoBranchErrorThrower(*this);
00064 }
00065
00066 private:
00067 const std::type_info* type_;
00068 const char* module_;
00069 const char* instance_;
00070 const char* process_;
00071 };
00072
00073 class UnsetErrorThrower : public ErrorThrower {
00074 void throwIt() const {
00075 throw cms::Exception("UnsetHandle")<<"The fwlite::Handle was never set";
00076 }
00077
00078 virtual ErrorThrower* clone() const {
00079 return new UnsetErrorThrower(*this);
00080 }
00081
00082 };
00083 }
00084
00085
00086
00087
00088
00089
00090
00091 ErrorThrower::ErrorThrower()
00092 {
00093 }
00094
00095
00096
00097
00098
00099
00100 ErrorThrower::~ErrorThrower()
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
00127 ErrorThrower*
00128 ErrorThrower::unsetErrorThrower() {
00129 return new UnsetErrorThrower();
00130 }
00131
00132 ErrorThrower*
00133 ErrorThrower::errorThrowerBranchNotFoundException(const std::type_info& iType, const char* iModule, const char* iInstance, const char* iProcess){
00134 return new NoBranchErrorThrower(iType,iModule,iInstance,iProcess);
00135 }
00136
00137 ErrorThrower*
00138 ErrorThrower::errorThrowerProductNotFoundException(const std::type_info& iType, const char* iModule, const char* iInstance, const char* iProcess){
00139 return new NoProductErrorThrower(iType,iModule,iInstance,iProcess);
00140 }