ATLAS Offline Software
Calorimeter/CaloCondBlobObjs/CaloCondBlobObjs/Exception.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef CALOCONDBLOBOBJS_EXCEPTION_H
6 #define CALOCONDBLOBOBJS_EXCEPTION_H
7 
8 #include <exception>
9 #include <string>
10 #include <sstream>
11 
12 namespace CaloCond {
13 
14  //
15  //__________________________________________________________________________________
20  class Exception : public std::exception {
21  public:
22  explicit Exception( const std::string& domain, const std::string& message)
23  : m_domain(domain), m_message(domain + ": " + message){}
24  virtual ~Exception() throw() {}
25 
26  virtual const char* what() const throw(){
27  return m_message.c_str();
28  }
29 
30  virtual const std::string& domain() const{
31  return m_domain;
32  }
33 
34  protected:
35  virtual void setMessage( const std::string& message ){
36  m_message = m_domain + ": " + message;
37  }
38 
39  private:
40  std::string m_domain;
41  std::string m_message;
42  };
43 
44 
45  //
46  //__________________________________________________________________________________
50  class InvalidBlob: public Exception {
51  public:
52  explicit InvalidBlob( const std::string& domain )
53  : Exception( domain, "Invalid Blob" )
54  {
55  }
56  virtual ~InvalidBlob() throw() {}
57  };
58 
59  //
60  //__________________________________________________________________________________
64  class VersionConflict: public Exception {
65  public:
66  explicit VersionConflict( const std::string& domain,
67  unsigned int version_is,
68  unsigned int version_should=0)
69  : Exception( domain, "" )
70  {
71  std::ostringstream msg;
72  msg << "Blob Version conflict. Is " << version_is;
73  if(version_should){ msg << " but should be " << version_should; }
74  setMessage(msg.str());
75  }
76  virtual ~VersionConflict() throw() {}
77  };
78 
79  //
80  //__________________________________________________________________________________
84  class TypeConflict: public Exception {
85  public:
86  explicit TypeConflict( const std::string& domain,
87  unsigned int version_is,
88  unsigned int version_should=0)
89  : Exception( domain, "" )
90  {
91  std::ostringstream msg;
92  msg << "Blob Type conflict. Is " << version_is;
93  if(version_should){ msg << " but should be " << version_should; }
94  setMessage(msg.str());
95  }
96  virtual ~TypeConflict() throw() {}
97  };
98 
99  //
100  //__________________________________________________________________________________
104  class SizeConflict: public Exception {
105  public:
106  explicit SizeConflict( const std::string& domain,
107  unsigned int size_is,
108  unsigned int size_should)
109  : Exception( domain, "" )
110  {
111  std::ostringstream msg;
112  msg << "Blob Size conflict. Is " << size_is
113  << " but should be " << size_should;
114  setMessage(msg.str());
115  }
116  virtual ~SizeConflict() throw() {}
117  };
118 
119  //
120  //__________________________________________________________________________________
124  class IndexOutOfRange : public Exception {
125  public:
126  explicit IndexOutOfRange( const std::string& domain,
127  unsigned int idx,
128  unsigned int maxRange=0)
129  : Exception( domain, "" )
130  {
131  std::ostringstream msg;
132  msg << "Index out of range: " << idx;
133  if(maxRange>0){
134  msg << " >= " << maxRange;
135  }
136  setMessage(msg.str());
137  }
138  virtual ~IndexOutOfRange() throw() {}
139  };
140 
141  //
142  //__________________________________________________________________________________
146  class InvalidCaloGain : public Exception {
147  public:
148  explicit InvalidCaloGain( const std::string& domain,
149  int caloGain)
150  : Exception( domain, "" )
151  {
152  std::ostringstream msg;
153  msg << "Invalid CaloGain: " << caloGain;
154  setMessage(msg.str());
155  }
156  virtual ~InvalidCaloGain() throw() {}
157  };
158 
159 }
160 #endif
CaloCond::InvalidCaloGain::InvalidCaloGain
InvalidCaloGain(const std::string &domain, int caloGain)
Definition: Calorimeter/CaloCondBlobObjs/CaloCondBlobObjs/Exception.h:148
CaloCond::Exception::Exception
Exception(const std::string &domain, const std::string &message)
Definition: Calorimeter/CaloCondBlobObjs/CaloCondBlobObjs/Exception.h:22
CaloCond::IndexOutOfRange::~IndexOutOfRange
virtual ~IndexOutOfRange()
Definition: Calorimeter/CaloCondBlobObjs/CaloCondBlobObjs/Exception.h:138
CaloCond::VersionConflict::VersionConflict
VersionConflict(const std::string &domain, unsigned int version_is, unsigned int version_should=0)
Definition: Calorimeter/CaloCondBlobObjs/CaloCondBlobObjs/Exception.h:66
CaloCond::Exception::m_message
std::string m_message
Definition: Calorimeter/CaloCondBlobObjs/CaloCondBlobObjs/Exception.h:41
CaloCond::Exception::m_domain
std::string m_domain
Definition: Calorimeter/CaloCondBlobObjs/CaloCondBlobObjs/Exception.h:40
ReweightUtils.message
message
Definition: ReweightUtils.py:15
CaloCond::InvalidCaloGain
Thrown if an invalid CaloGain is encountered.
Definition: Calorimeter/CaloCondBlobObjs/CaloCondBlobObjs/Exception.h:146
CaloCond::TypeConflict
Thrown if object type in BLOB does not agree with class type.
Definition: Calorimeter/CaloCondBlobObjs/CaloCondBlobObjs/Exception.h:84
CaloCond::Exception::~Exception
virtual ~Exception()
Definition: Calorimeter/CaloCondBlobObjs/CaloCondBlobObjs/Exception.h:24
CaloCond::TypeConflict::TypeConflict
TypeConflict(const std::string &domain, unsigned int version_is, unsigned int version_should=0)
Definition: Calorimeter/CaloCondBlobObjs/CaloCondBlobObjs/Exception.h:86
CaloCond::VersionConflict::~VersionConflict
virtual ~VersionConflict()
Definition: Calorimeter/CaloCondBlobObjs/CaloCondBlobObjs/Exception.h:76
CaloCond::InvalidCaloGain::~InvalidCaloGain
virtual ~InvalidCaloGain()
Definition: Calorimeter/CaloCondBlobObjs/CaloCondBlobObjs/Exception.h:156
CaloCond::Exception::domain
virtual const std::string & domain() const
Definition: Calorimeter/CaloCondBlobObjs/CaloCondBlobObjs/Exception.h:30
CaloCond::InvalidBlob::~InvalidBlob
virtual ~InvalidBlob()
Definition: Calorimeter/CaloCondBlobObjs/CaloCondBlobObjs/Exception.h:56
calibdata.exception
exception
Definition: calibdata.py:496
CaloCond::IndexOutOfRange::IndexOutOfRange
IndexOutOfRange(const std::string &domain, unsigned int idx, unsigned int maxRange=0)
Definition: Calorimeter/CaloCondBlobObjs/CaloCondBlobObjs/Exception.h:126
CaloCond::VersionConflict
Thrown if object version in BLOB does not agree with class version.
Definition: Calorimeter/CaloCondBlobObjs/CaloCondBlobObjs/Exception.h:64
CaloCond::InvalidBlob
Thrown if coral::Blob does not conform with expected structure.
Definition: Calorimeter/CaloCondBlobObjs/CaloCondBlobObjs/Exception.h:50
CaloCond::IndexOutOfRange
Thrown if an index is out of range.
Definition: Calorimeter/CaloCondBlobObjs/CaloCondBlobObjs/Exception.h:124
CaloCond::Exception
Calocond Exception base class.
Definition: Calorimeter/CaloCondBlobObjs/CaloCondBlobObjs/Exception.h:20
CaloCond::Exception::what
virtual const char * what() const
Definition: Calorimeter/CaloCondBlobObjs/CaloCondBlobObjs/Exception.h:26
CaloCond::InvalidBlob::InvalidBlob
InvalidBlob(const std::string &domain)
Definition: Calorimeter/CaloCondBlobObjs/CaloCondBlobObjs/Exception.h:52
CaloCond::TypeConflict::~TypeConflict
virtual ~TypeConflict()
Definition: Calorimeter/CaloCondBlobObjs/CaloCondBlobObjs/Exception.h:96
CaloCond::Exception::setMessage
virtual void setMessage(const std::string &message)
Definition: Calorimeter/CaloCondBlobObjs/CaloCondBlobObjs/Exception.h:35
CaloCond::SizeConflict::SizeConflict
SizeConflict(const std::string &domain, unsigned int size_is, unsigned int size_should)
Definition: Calorimeter/CaloCondBlobObjs/CaloCondBlobObjs/Exception.h:106
CaloCond
Definition: Calorimeter/CaloCondBlobObjs/CaloCondBlobObjs/Exception.h:12
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
CaloCond::SizeConflict::~SizeConflict
virtual ~SizeConflict()
Definition: Calorimeter/CaloCondBlobObjs/CaloCondBlobObjs/Exception.h:116
CaloCond::SizeConflict
Thrown if BLOB size is not correct.
Definition: Calorimeter/CaloCondBlobObjs/CaloCondBlobObjs/Exception.h:104