ATLAS Offline Software
Loading...
Searching...
No Matches
TileCalorimeter/TileCalib/TileCalibBlobObjs/TileCalibBlobObjs/Exception.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef TILECALIBBLOBOBJS_EXCEPTION_H
6#define TILECALIBBLOBOBJS_EXCEPTION_H
7
8
9#include <exception>
10#include <string>
11#include <sstream>
12
13namespace TileCalib {
14
15
16 //
17 //__________________________________________________________________________________
22 class Exception : public std::exception {
23 public:
24 explicit Exception( const std::string& domain, const std::string& message)
25 : m_domain(domain), m_message(message)
26 {
27 format();
28 }
29 virtual ~Exception() throw() {}
30
31 virtual const char* what() const throw(){
32 return m_result.c_str();
33 }
34
35 virtual const std::string& domain() const{
36 return m_domain;
37 }
38
39 protected:
40 virtual void setMessage( const std::string& message ){
41 m_message = message;
42 format();
43 }
44
45 private:
46 void format()
47 {
48 m_result = m_domain + ": "+ m_message;
49 }
50
51 std::string m_domain;
52 std::string m_message;
53 std::string m_result;
54 };
55
56
57 //
58 //__________________________________________________________________________________
63 class InvalidBlob: public Exception {
64 public:
65 explicit InvalidBlob( const std::string& domain )
66 : Exception( domain, "Invalid Blob" )
67 {
68 }
69 virtual ~InvalidBlob() throw() {}
70 };
71
72 //
73 //__________________________________________________________________________________
78 class VersionConflict: public Exception {
79 public:
80 explicit VersionConflict( const std::string& domain,
81 unsigned int version_is,
82 unsigned int version_should=0)
83 : Exception( domain, "" )
84 {
85 std::ostringstream msg;
86 msg << "Blob Version conflict. Is " << version_is;
87 if(version_should){ msg << " but should be " << version_should; }
88 setMessage(msg.str());
89 }
90 virtual ~VersionConflict() throw() {}
91 };
92
93 //
94 //__________________________________________________________________________________
99 class TypeConflict: public Exception {
100 public:
101 explicit TypeConflict( const std::string& domain,
102 unsigned int version_is,
103 unsigned int version_should=0)
104 : Exception( domain, "" )
105 {
106 std::ostringstream msg;
107 msg << "Blob Type conflict. Is " << version_is;
108 if(version_should){ msg << " but should be " << version_should; }
109 setMessage(msg.str());
110 }
111 virtual ~TypeConflict() throw() {}
112 };
113
114 //
115 //__________________________________________________________________________________
120 class SizeConflict: public Exception {
121 public:
122 explicit SizeConflict( const std::string& domain,
123 unsigned int size_is,
124 unsigned int size_should)
125 : Exception( domain, "" )
126 {
127 std::ostringstream msg;
128 msg << "Blob Size conflict. Is " << size_is
129 << " but should be " << size_should;
130 setMessage(msg.str());
131 }
132 virtual ~SizeConflict() throw() {}
133 };
134
135 //
136 //__________________________________________________________________________________
141 class IndexOutOfRange : public Exception {
142 public:
143 explicit IndexOutOfRange( const std::string& domain,
144 unsigned int idx,
145 unsigned int maxRange=0)
146 : Exception( domain, "" )
147 {
148 std::ostringstream msg;
149 msg << "Index out of range: " << idx;
150 if(maxRange>0){
151 msg << " >= " << maxRange;
152 }
153 setMessage(msg.str());
154 }
155 virtual ~IndexOutOfRange() throw() {}
156 };
157
158
159 //
160 //__________________________________________________________________________________
165 class NoSuchPhase : public Exception {
166 public:
167 explicit NoSuchPhase( const std::string& domain,
168 int phase)
169 : Exception( domain, "" )
170 {
171 std::ostringstream msg;
172 msg << "No such phase: " << phase;
173 setMessage(msg.str());
174 }
175 virtual ~NoSuchPhase() throw() {}
176 };
177
178
179 //
180 //__________________________________________________________________________________
186 public:
187 explicit InvalidBitPattern( const std::string& domain,
188 int version)
189 : Exception( domain, "" )
190 {
191 std::ostringstream msg;
192 msg << "Invalid bit pattern version: " << version;
193 setMessage(msg.str());
194 }
195 virtual ~InvalidBitPattern() throw() {}
196 };
197
198 //
199 //__________________________________________________________________________________
205 public:
206 explicit InvalidBchProblem( const std::string& domain,
207 unsigned int prb)
208 : Exception( domain, "" )
209 {
210 std::ostringstream msg;
211 msg << "Problem not encodable in current bit pattern: " << prb;
212 setMessage(msg.str());
213 }
214 virtual ~InvalidBchProblem() throw() {}
215 };
216
217
218 //
219 //__________________________________________________________________________________
224 class InvalidValue : public Exception {
225 public:
226 explicit InvalidValue( const std::string& domain,
227 float value)
228 : Exception( domain, "" )
229 {
230 std::ostringstream msg;
231 msg << "Invalid value: " << value;
232 setMessage(msg.str());
233 }
234 virtual ~InvalidValue() throw() {}
235 };
236
237}
238#endif
Exception(const std::string &domain, const std::string &message)
IndexOutOfRange(const std::string &domain, unsigned int idx, unsigned int maxRange=0)
SizeConflict(const std::string &domain, unsigned int size_is, unsigned int size_should)
TypeConflict(const std::string &domain, unsigned int version_is, unsigned int version_should=0)
VersionConflict(const std::string &domain, unsigned int version_is, unsigned int version_should=0)
MsgStream & msg
Definition testRead.cxx:32