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 // $Id: ErrorThrower.cc,v 1.3 2008/11/04 20:38:55 elmer Exp $
12 //
13 
14 // system include files
15 
16 // user include files
20 #include <ostream>
21 
22 using namespace fwlite;
23 //
24 // constants, enums and typedefs
25 //
26 namespace {
27  class NoProductErrorThrower : public ErrorThrower {
28  public:
29  NoProductErrorThrower(const std::type_info& iType, const char*iModule, const char*iInstance, const char*iProcess):
30  type_(&iType), module_(iModule), instance_(iInstance), process_(iProcess) {}
31 
32  void throwIt() const {
33 
34  edm::TypeID type(*type_);
35  throw edm::Exception(edm::errors::ProductNotFound)<<"A branch was found for \n type ='"<<type.className()<<"'\n module='"<<module_
36  <<"'\n productInstance='"<<((0!=instance_)?instance_:"")<<"'\n process='"<<((0!=process_)?process_:"")<<"'\n"
37  "but no data is available for this Event";
38  }
39  virtual ErrorThrower* clone() const {
40  return new NoProductErrorThrower(*this);
41  }
42 
43  private:
44  const std::type_info* type_;
45  const char* module_;
46  const char* instance_;
47  const char* process_;
48  };
49 
50  class NoBranchErrorThrower : public ErrorThrower {
51  public:
52  NoBranchErrorThrower(const std::type_info& iType, const char*iModule, const char*iInstance, const char*iProcess):
53  type_(&iType), module_(iModule), instance_(iInstance), process_(iProcess) {}
54 
55  void throwIt() const {
56 
57  edm::TypeID type(*type_);
58  throw edm::Exception(edm::errors::ProductNotFound)<<"No branch was found for \n type ='"<<type.className()<<"'\n module='"<<module_
59  <<"'\n productInstance='"<<((0!=instance_)?instance_:"")<<"'\n process='"<<((0!=process_)?process_:"")<<"'";
60  }
61 
62  virtual ErrorThrower* clone() const {
63  return new NoBranchErrorThrower(*this);
64  }
65 
66  private:
67  const std::type_info* type_;
68  const char* module_;
69  const char* instance_;
70  const char* process_;
71  };
72 
73  class UnsetErrorThrower : public ErrorThrower {
74  void throwIt() const {
75  throw cms::Exception("UnsetHandle")<<"The fwlite::Handle was never set";
76  }
77 
78  virtual ErrorThrower* clone() const {
79  return new UnsetErrorThrower(*this);
80  }
81 
82  };
83 }
84 //
85 // static data member definitions
86 //
87 
88 //
89 // constructors and destructor
90 //
92 {
93 }
94 
95 // ErrorThrower::ErrorThrower(const ErrorThrower& rhs)
96 // {
97 // // do actual copying here;
98 // }
99 
101 {
102 }
103 
104 //
105 // assignment operators
106 //
107 // const ErrorThrower& ErrorThrower::operator=(const ErrorThrower& rhs)
108 // {
109 // //An exception safe implementation is
110 // ErrorThrower temp(rhs);
111 // swap(rhs);
112 //
113 // return *this;
114 // }
115 
116 //
117 // member functions
118 //
119 
120 //
121 // const member functions
122 //
123 
124 //
125 // static member functions
126 //
127 ErrorThrower*
129  return new UnsetErrorThrower();
130 }
131 
132 ErrorThrower*
133 ErrorThrower::errorThrowerBranchNotFoundException(const std::type_info& iType, const char* iModule, const char* iInstance, const char* iProcess){
134  return new NoBranchErrorThrower(iType,iModule,iInstance,iProcess);
135 }
136 
137 ErrorThrower*
138 ErrorThrower::errorThrowerProductNotFoundException(const std::type_info& iType, const char* iModule, const char* iInstance, const char* iProcess){
139  return new NoProductErrorThrower(iType,iModule,iInstance,iProcess);
140 }
static const char module_[]
type
Definition: HCALResponse.h:22
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 *)
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135