ATLAS Offline Software
Control/AthLinks/src/exceptions.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
12 #include "AthLinks/exceptions.h"
13 #include <sstream>
14 #include <string>
15 
16 
17 namespace SG {
18 
19 
21 void AthLinks_error() {}
22 
23 
24 //*************************************************************************
25 
26 
28 std::string excPointerNotInSG_format (const void* pointer)
29 {
30  std::ostringstream os;
31  os << "SG::ExcPointerNotInSG: "
32  << "The object referenced by a DataLink / ElementLink is not registered "
33  << "in StoreGate: " << pointer << ".";
34  return os.str();
35 }
36 
37 
43  : std::runtime_error (excPointerNotInSG_format (pointer))
44 {
46 }
47 
48 
49 //*************************************************************************
50 
51 
53 std::string excCLIDMismatch_format (CLID obj_clid, CLID link_clid)
54 {
55  std::ostringstream os;
56  os << "SG::ExcCLIDMismatch: "
57  << "Attempt to set DataLink / ElementLink with CLID " << link_clid
58  << " to object with CLID " << obj_clid;
59  return os.str();
60 }
61 
62 
69  : std::runtime_error (excCLIDMismatch_format (obj_clid, link_clid))
70 {
72 }
73 
74 
75 //*************************************************************************
76 
77 
79 std::string
80 excInvalidLink_format (CLID clid, const std::string& key, SG::sgkey_t sgkey)
81 {
82  std::ostringstream os;
83  os << "SG::ExcInvalidLink: "
84  << "Attempt to dereference invalid DataLink / ElementLink "
85  << "[" << clid << "/" << key << "] (" << sgkey << ")";
86  return os.str();
87 }
88 
89 
97  const std::string& key,
99  : std::runtime_error (excInvalidLink_format (clid, key, sgkey))
100 {
101  AthLinks_error();
102 }
103 
104 
111 void throwExcInvalidLink (CLID clid, const std::string& key, SG::sgkey_t sgkey)
112 {
113  throw ExcInvalidLink (clid, key, sgkey);
114 }
115 
116 
117 //*************************************************************************
118 
119 
121 std::string
122 excBadForwardLink_format (size_t index, size_t size, const std::string& name)
123 {
124  std::ostringstream os;
125  os << "SG::ExcBadForwardLink: "
126  << "ForwardIndexingPolicy: internal link state of '" << name << "' is invalid";
127  if (index != static_cast<size_t>(-1)) {
128  os << ": m_index = " << index
129  << " is >= data container size = "
130  << size << std::ends;
131  }
132  return os.str();
133 }
134 
135 
142 ExcBadForwardLink::ExcBadForwardLink (size_t index, size_t size, const std::string& name)
143  : std::runtime_error (excBadForwardLink_format (index, size, name))
144 {
145  AthLinks_error();
146 }
147 
148 
155 void throwExcBadForwardLink (size_t index, size_t size, const std::string& name)
156 {
157  throw ExcBadForwardLink (index, size, name);
158 }
159 
160 
161 //*************************************************************************
162 
163 
169  : std::runtime_error ("SG::ExcElementNotFound: " + where +
170  ": element not found")
171 {
172  AthLinks_error();
173 }
174 
175 
180 void throwExcElementNotFound (const char* where)
181 {
182  throw ExcElementNotFound (where);
183 }
184 
185 
186 //*************************************************************************
187 
188 
194  : std::runtime_error ("SG::ExcInvalidIndex: " + where + ": invalid index")
195 {
196  AthLinks_error();
197 }
198 
199 
204 void throwExcInvalidIndex (const char* where)
205 {
206  throw ExcInvalidIndex (where);
207 }
208 
209 
210 //*************************************************************************
211 
212 
218  : std::runtime_error ("SG::ExcIndexNotFound: " + where + ": index not found")
219 {
220  AthLinks_error();
221 }
222 
223 
228 void throwExcIndexNotFound (const char* where)
229 {
230  throw ExcIndexNotFound (where);
231 }
232 
233 
234 //*************************************************************************
235 
236 
241  : std::runtime_error ("SG::ExcIncomparableEL: Attempt to compare an ElementLink that does not have a SG key or index.")
242 {
243  AthLinks_error();
244 }
245 
246 
251 {
252  throw ExcIncomparableEL();
253 }
254 
255 
256 //*************************************************************************
257 
258 
263  : std::runtime_error ("SG::ExcBadToTransient: toTransient() called on an already-initialized link.")
264 {
265  AthLinks_error();
266 }
267 
268 
273 {
274  throw ExcBadToTransient();
275 }
276 
277 
278 //*************************************************************************
279 
280 
282 std::string
283 excConstStorable_format (CLID clid, const std::string& key, SG::sgkey_t sgkey)
284 {
285  std::ostringstream os;
286  os << "SG::ExcConstStorable: "
287  << "Tried to retrieve const storable as a non-const pointer "
288  << "[" << clid << "/" << key << "] (" << sgkey << ")";
289  return os.str();
290 }
291 
292 
300  const std::string& key,
302  : std::runtime_error (excConstStorable_format (clid, key, sgkey))
303 {
304  AthLinks_error();
305 }
306 
307 
308 //*************************************************************************
309 
310 
312 std::string
313 excBadThinning_format (CLID clid, const std::string& key, SG::sgkey_t sgkey)
314 {
315  std::ostringstream os;
316  os << "SG::ExcBadThinning: "
317  << "Bad thinning request "
318  << "[" << clid << "/" << key << "] (" << sgkey << ")";
319  return os.str();
320 }
321 
322 
330  const std::string& key,
332  : std::runtime_error (excBadThinning_format (clid, key, sgkey))
333 {
334  AthLinks_error();
335 }
336 
337 
345  const std::string& key,
347 {
348  throw ExcBadThinning (clid, key, sgkey);
349 }
350 
351 
352 } // namespace SG
SG::ExcPointerNotInSG::ExcPointerNotInSG
ExcPointerNotInSG(const void *pointer)
Constructor.
Definition: Control/AthLinks/src/exceptions.cxx:42
SG::ExcBadToTransient
Exception — bad toTransient.
Definition: Control/AthLinks/AthLinks/exceptions.h:251
common.sgkey
def sgkey(tool)
Definition: common.py:1028
SG::ExcIndexNotFound
Exception — index not found.
Definition: Control/AthLinks/AthLinks/exceptions.h:199
SG::excBadThinning_format
std::string excBadThinning_format(CLID clid, const std::string &key, SG::sgkey_t sgkey)
Helper: format exception error string.
Definition: Control/AthLinks/src/exceptions.cxx:313
SG::throwExcElementNotFound
void throwExcElementNotFound(const char *where)
Throw a SG::ExcElementNotFound exception.
Definition: Control/AthLinks/src/exceptions.cxx:180
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
SG::excConstStorable_format
std::string excConstStorable_format(CLID clid, const std::string &key, SG::sgkey_t sgkey)
Helper: format exception error string.
Definition: Control/AthLinks/src/exceptions.cxx:283
index
Definition: index.py:1
SG::excCLIDMismatch_format
std::string excCLIDMismatch_format(CLID obj_clid, CLID link_clid)
Helper: format exception error string.
Definition: Control/AthLinks/src/exceptions.cxx:53
SG::throwExcInvalidIndex
void throwExcInvalidIndex(const char *where)
Throw a SG::ExcInvalidIndex exception.
Definition: Control/AthLinks/src/exceptions.cxx:204
SG::excPointerNotInSG_format
std::string excPointerNotInSG_format(const void *pointer)
Helper: format exception error string.
Definition: Control/AthLinks/src/exceptions.cxx:28
SG::throwExcBadThinning
void throwExcBadThinning(CLID clid, const std::string &key, SG::sgkey_t sgkey)
Throw a SG::ExcBadThinning exception.
Definition: Control/AthLinks/src/exceptions.cxx:344
SG::ExcCLIDMismatch::ExcCLIDMismatch
ExcCLIDMismatch(CLID obj_clid, CLID link_clid)
Constructor.
Definition: Control/AthLinks/src/exceptions.cxx:68
SG::throwExcBadToTransient
void throwExcBadToTransient()
Throw a SG::ExcBadToTransient exception.
Definition: Control/AthLinks/src/exceptions.cxx:272
SG::ExcInvalidIndex
Exception — invalid index.
Definition: Control/AthLinks/AthLinks/exceptions.h:172
SG::ExcBadToTransient::ExcBadToTransient
ExcBadToTransient()
Constructor.
Definition: Control/AthLinks/src/exceptions.cxx:262
SG::throwExcInvalidLink
void throwExcInvalidLink(CLID clid, const std::string &key, SG::sgkey_t sgkey)
Throw a SG::ExcInvalidLink exception.
Definition: Control/AthLinks/src/exceptions.cxx:111
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
SG::ExcIncomparableEL::ExcIncomparableEL
ExcIncomparableEL()
Constructor.
Definition: Control/AthLinks/src/exceptions.cxx:240
SG::excInvalidLink_format
std::string excInvalidLink_format(CLID clid, const std::string &key, SG::sgkey_t sgkey)
Helper: format exception error string.
Definition: Control/AthLinks/src/exceptions.cxx:80
SG::ExcElementNotFound
Exception — element not found.
Definition: Control/AthLinks/AthLinks/exceptions.h:142
SG::throwExcBadForwardLink
void throwExcBadForwardLink(size_t index, size_t size, const std::string &name)
Throw a SG::ExcBadForwardLink exception.
Definition: Control/AthLinks/src/exceptions.cxx:155
python.Utils.unixtools.where
def where(filename, prepath=[])
"which" for python files -------------------------------------------------—
Definition: unixtools.py:53
SG::ExcBadThinning::ExcBadThinning
ExcBadThinning(CLID clid, const std::string &key, SG::sgkey_t sgkey)
Constructor.
Definition: Control/AthLinks/src/exceptions.cxx:329
SG::ExcInvalidIndex::ExcInvalidIndex
ExcInvalidIndex(const std::string &where)
Constructor.
Definition: Control/AthLinks/src/exceptions.cxx:193
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
SG::AthLinks_error
void AthLinks_error()
For setting debugger breakpoints.
Definition: Control/AthLinks/src/exceptions.cxx:21
SG::ExcElementNotFound::ExcElementNotFound
ExcElementNotFound(const std::string &where)
Constructor.
Definition: Control/AthLinks/src/exceptions.cxx:168
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
SG::ExcBadThinning
Exception – Bad thinning request.
Definition: Control/AthLinks/AthLinks/exceptions.h:294
SG::throwExcIncomparableEL
void throwExcIncomparableEL()
Throw a SG::IncomparableEL exception.
Definition: Control/AthLinks/src/exceptions.cxx:250
SG::sgkey_t
uint32_t sgkey_t
Type used for hashed StoreGate key+CLID pairs.
Definition: CxxUtils/CxxUtils/sgkey_t.h:32
SG::throwExcIndexNotFound
void throwExcIndexNotFound(const char *where)
Throw a SG::ExcIndexNotFound exception.
Definition: Control/AthLinks/src/exceptions.cxx:228
SG::excBadForwardLink_format
std::string excBadForwardLink_format(size_t index, size_t size, const std::string &name)
Helper: format exception error string.
Definition: Control/AthLinks/src/exceptions.cxx:122
SG::ExcIncomparableEL
Exception — incomparable ElementLink.
Definition: Control/AthLinks/AthLinks/exceptions.h:228
SG::ExcIndexNotFound::ExcIndexNotFound
ExcIndexNotFound(const std::string &where)
Constructor.
Definition: Control/AthLinks/src/exceptions.cxx:217
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
SG::ExcConstStorable::ExcConstStorable
ExcConstStorable(CLID clid, const std::string &key, SG::sgkey_t sgkey)
Constructor.
Definition: Control/AthLinks/src/exceptions.cxx:299