ATLAS Offline Software
Loading...
Searching...
No Matches
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*/
10
11
12#include "AthLinks/exceptions.h"
13#include <sstream>
14#include <string>
15
16
17namespace SG {
18
19
22
23
24//*************************************************************************
25
26
28std::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
47
48
49//*************************************************************************
50
51
53std::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
79std::string
80excInvalidLink_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,
98 SG::sgkey_t sgkey)
99 : std::runtime_error (excInvalidLink_format (clid, key, sgkey))
100{
102}
103
104
111void throwExcInvalidLink (CLID clid, const std::string& key, SG::sgkey_t sgkey)
112{
113 throw ExcInvalidLink (clid, key, sgkey);
114}
115
116
117//*************************************************************************
118
119
121std::string
122excBadForwardLink_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
142ExcBadForwardLink::ExcBadForwardLink (size_t index, size_t size, const std::string& name)
144{
146}
147
148
155void 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{
173}
174
175
180void throwExcElementNotFound (const char* where)
181{
182 throw ExcElementNotFound (where);
183}
184
185
186//*************************************************************************
187
188
193ExcInvalidIndex::ExcInvalidIndex (const std::string& where)
194 : std::runtime_error ("SG::ExcInvalidIndex: " + where + ": invalid index")
195{
197}
198
199
204void throwExcInvalidIndex (const char* where)
205{
206 throw ExcInvalidIndex (where);
207}
208
209
210//*************************************************************************
211
212
217ExcIndexNotFound::ExcIndexNotFound (const std::string& where)
218 : std::runtime_error ("SG::ExcIndexNotFound: " + where + ": index not found")
219{
221}
222
223
228void 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{
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{
266}
267
268
273{
274 throw ExcBadToTransient();
275}
276
277
278//*************************************************************************
279
280
282std::string
283excConstStorable_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,
301 SG::sgkey_t sgkey)
302 : std::runtime_error (excConstStorable_format (clid, key, sgkey))
303{
305}
306
307
308//*************************************************************************
309
310
312std::string
313excBadThinning_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,
331 SG::sgkey_t sgkey)
332 : std::runtime_error (excBadThinning_format (clid, key, sgkey))
333{
335}
336
337
345 const std::string& key,
346 SG::sgkey_t sgkey)
347{
348 throw ExcBadThinning (clid, key, sgkey);
349}
350
351
352} // namespace SG
uint32_t CLID
The Class ID type.
Exception – Bad thinning request.
ExcBadThinning(CLID clid, const std::string &key, SG::sgkey_t sgkey)
Constructor.
ExcCLIDMismatch(CLID obj_clid, CLID link_clid)
Constructor.
ExcConstStorable(CLID clid, const std::string &key, SG::sgkey_t sgkey)
Constructor.
Exception — element not found.
ExcElementNotFound(const std::string &where)
Constructor.
Exception — incomparable ElementLink.
ExcIndexNotFound(const std::string &where)
Constructor.
ExcInvalidIndex(const std::string &where)
Constructor.
ExcPointerNotInSG(const void *pointer)
Constructor.
STL class.
Forward declaration.
std::string excInvalidLink_format(CLID clid, const std::string &key, SG::sgkey_t sgkey)
Helper: format exception error string.
void throwExcElementNotFound(const char *where)
Throw a SG::ExcElementNotFound exception.
std::string excCLIDMismatch_format(CLID obj_clid, CLID link_clid)
Helper: format exception error string.
void throwExcBadToTransient()
Throw a SG::ExcBadToTransient exception.
std::string excConstStorable_format(CLID clid, const std::string &key, SG::sgkey_t sgkey)
Helper: format exception error string.
void AthLinks_error()
For setting debugger breakpoints.
uint32_t sgkey_t
Type used for hashed StoreGate key+CLID pairs.
Definition sgkey_t.h:32
void throwExcInvalidLink(CLID clid, const std::string &key, SG::sgkey_t sgkey)
Throw a SG::ExcInvalidLink exception.
void throwExcIncomparableEL()
Throw a SG::IncomparableEL exception.
void throwExcBadThinning(CLID clid, const std::string &key, SG::sgkey_t sgkey)
Throw a SG::ExcBadThinning exception.
void throwExcIndexNotFound(const char *where)
Throw a SG::ExcIndexNotFound exception.
std::string excPointerNotInSG_format(const void *pointer)
Helper: format exception error string.
std::string excBadForwardLink_format(size_t index, size_t size, const std::string &name)
Helper: format exception error string.
std::string excBadThinning_format(CLID clid, const std::string &key, SG::sgkey_t sgkey)
Helper: format exception error string.
void throwExcInvalidIndex(const char *where)
Throw a SG::ExcInvalidIndex exception.
void throwExcBadForwardLink(size_t index, size_t size, const std::string &name)
Throw a SG::ExcBadForwardLink exception.
Definition index.py:1
STL namespace.