File indexing completed on 2024-04-06 12:04:10
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #include "DataFormats/FWLite/interface/ErrorThrower.h"
0017 #include "FWCore/Utilities/interface/EDMException.h"
0018 #include "FWCore/Utilities/interface/TypeID.h"
0019 #include <ostream>
0020
0021 using namespace fwlite;
0022
0023
0024
0025 namespace {
0026 class NoProductErrorThrower : public ErrorThrower {
0027 public:
0028 NoProductErrorThrower(const std::type_info& iType, const char* iModule, const char* iInstance, const char* iProcess)
0029 : type_(&iType), module_(iModule), instance_(iInstance), process_(iProcess) {}
0030
0031 void throwIt() const override {
0032 edm::TypeID type(*type_);
0033 throw edm::Exception(edm::errors::ProductNotFound)
0034 << "A branch was found for \n type ='" << type.className() << "'\n module='" << module_
0035 << "'\n productInstance='" << ((nullptr != instance_) ? instance_ : "") << "'\n process='"
0036 << ((nullptr != process_) ? process_ : "")
0037 << "'\n"
0038 "but no data is available for this Event";
0039 }
0040 ErrorThrower* clone() const override { return new NoProductErrorThrower(*this); }
0041
0042 private:
0043 const std::type_info* type_;
0044 const char* module_;
0045 const char* instance_;
0046 const char* process_;
0047 };
0048
0049 class NoBranchErrorThrower : public ErrorThrower {
0050 public:
0051 NoBranchErrorThrower(const std::type_info& iType, const char* iModule, const char* iInstance, const char* iProcess)
0052 : type_(&iType), module_(iModule), instance_(iInstance), process_(iProcess) {}
0053
0054 void throwIt() const override {
0055 edm::TypeID type(*type_);
0056 throw edm::Exception(edm::errors::ProductNotFound)
0057 << "No branch was found for \n type ='" << type.className() << "'\n module='" << module_
0058 << "'\n productInstance='" << ((nullptr != instance_) ? instance_ : "") << "'\n process='"
0059 << ((nullptr != process_) ? process_ : "") << "'";
0060 }
0061
0062 ErrorThrower* clone() const override { return new NoBranchErrorThrower(*this); }
0063
0064 private:
0065 const std::type_info* type_;
0066 const char* module_;
0067 const char* instance_;
0068 const char* process_;
0069 };
0070
0071 class UnsetErrorThrower : public ErrorThrower {
0072 void throwIt() const override { throw cms::Exception("UnsetHandle") << "The fwlite::Handle was never set"; }
0073
0074 ErrorThrower* clone() const override { return new UnsetErrorThrower(*this); }
0075 };
0076 }
0077
0078
0079
0080
0081
0082
0083
0084 ErrorThrower::ErrorThrower() {}
0085
0086
0087
0088
0089
0090
0091 ErrorThrower::~ErrorThrower() {}
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116 ErrorThrower* ErrorThrower::unsetErrorThrower() { return new UnsetErrorThrower(); }
0117
0118 ErrorThrower* ErrorThrower::errorThrowerBranchNotFoundException(const std::type_info& iType,
0119 const char* iModule,
0120 const char* iInstance,
0121 const char* iProcess) {
0122 return new NoBranchErrorThrower(iType, iModule, iInstance, iProcess);
0123 }
0124
0125 ErrorThrower* ErrorThrower::errorThrowerProductNotFoundException(const std::type_info& iType,
0126 const char* iModule,
0127 const char* iInstance,
0128 const char* iProcess) {
0129 return new NoProductErrorThrower(iType, iModule, iInstance, iProcess);
0130 }