CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ErrorThrower.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: FWLite
4 // Class : ErrorThrower
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author: Chris Jones
10 // Created: Tue Sep 23 10:06:39 EDT 2008
11 //
12 
13 // system include files
14 
15 // user include files
19 #include <ostream>
20 
21 using namespace fwlite;
22 //
23 // constants, enums and typedefs
24 //
25 namespace {
26  class NoProductErrorThrower : public ErrorThrower {
27  public:
28  NoProductErrorThrower(const std::type_info& iType, const char*iModule, const char*iInstance, const char*iProcess):
29  type_(&iType), module_(iModule), instance_(iInstance), process_(iProcess) {}
30 
31  void throwIt() const override {
32 
33  edm::TypeID type(*type_);
34  throw edm::Exception(edm::errors::ProductNotFound)<<"A branch was found for \n type ='"<<type.className()<<"'\n module='"<<module_
35  <<"'\n productInstance='"<<((0!=instance_)?instance_:"")<<"'\n process='"<<((0!=process_)?process_:"")<<"'\n"
36  "but no data is available for this Event";
37  }
38  virtual ErrorThrower* clone() const override {
39  return new NoProductErrorThrower(*this);
40  }
41 
42  private:
43  const std::type_info* type_;
44  const char* module_;
45  const char* instance_;
46  const char* process_;
47  };
48 
49  class NoBranchErrorThrower : public ErrorThrower {
50  public:
51  NoBranchErrorThrower(const std::type_info& iType, const char*iModule, const char*iInstance, const char*iProcess):
52  type_(&iType), module_(iModule), instance_(iInstance), process_(iProcess) {}
53 
54  void throwIt() const override {
55 
56  edm::TypeID type(*type_);
57  throw edm::Exception(edm::errors::ProductNotFound)<<"No branch was found for \n type ='"<<type.className()<<"'\n module='"<<module_
58  <<"'\n productInstance='"<<((0!=instance_)?instance_:"")<<"'\n process='"<<((0!=process_)?process_:"")<<"'";
59  }
60 
61  virtual ErrorThrower* clone() const override {
62  return new NoBranchErrorThrower(*this);
63  }
64 
65  private:
66  const std::type_info* type_;
67  const char* module_;
68  const char* instance_;
69  const char* process_;
70  };
71 
72  class UnsetErrorThrower : public ErrorThrower {
73  void throwIt() const override {
74  throw cms::Exception("UnsetHandle")<<"The fwlite::Handle was never set";
75  }
76 
77  virtual ErrorThrower* clone() const override {
78  return new UnsetErrorThrower(*this);
79  }
80 
81  };
82 }
83 //
84 // static data member definitions
85 //
86 
87 //
88 // constructors and destructor
89 //
91 {
92 }
93 
94 // ErrorThrower::ErrorThrower(const ErrorThrower& rhs)
95 // {
96 // // do actual copying here;
97 // }
98 
100 {
101 }
102 
103 //
104 // assignment operators
105 //
106 // const ErrorThrower& ErrorThrower::operator=(const ErrorThrower& rhs)
107 // {
108 // //An exception safe implementation is
109 // ErrorThrower temp(rhs);
110 // swap(rhs);
111 //
112 // return *this;
113 // }
114 
115 //
116 // member functions
117 //
118 
119 //
120 // const member functions
121 //
122 
123 //
124 // static member functions
125 //
126 ErrorThrower*
128  return new UnsetErrorThrower();
129 }
130 
131 ErrorThrower*
132 ErrorThrower::errorThrowerBranchNotFoundException(const std::type_info& iType, const char* iModule, const char* iInstance, const char* iProcess){
133  return new NoBranchErrorThrower(iType,iModule,iInstance,iProcess);
134 }
135 
136 ErrorThrower*
137 ErrorThrower::errorThrowerProductNotFoundException(const std::type_info& iType, const char* iModule, const char* iInstance, const char* iProcess){
138  return new NoProductErrorThrower(iType,iModule,iInstance,iProcess);
139 }
static const char module_[]
type
Definition: HCALResponse.h:21
static ErrorThrower * unsetErrorThrower()
static ErrorThrower * errorThrowerBranchNotFoundException(const std::type_info &, const char *, const char *, const char *)
static ErrorThrower * errorThrowerProductNotFoundException(const std::type_info &, const char *, const char *, const char *)
tuple clone
Definition: statics.py:58