ATLAS Offline Software
Loading...
Searching...
No Matches
Control/AthLinks/src/exceptions.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 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 return std::format ("SG::ExcPointerNotInSG: "
31 "The object referenced by a DataLink / ElementLink is not registered "
32 "in StoreGate: {}.", pointer);
33}
34
35
41 : std::runtime_error (excPointerNotInSG_format (pointer))
42{
44}
45
46
47//*************************************************************************
48
49
51std::string excCLIDMismatch_format (CLID obj_clid, CLID link_clid)
52{
53 return std::format ("SG::ExcCLIDMismatch: "
54 "Attempt to set DataLink / ElementLink with CLID {} to object with CLID {}",
55 link_clid, obj_clid);
56}
57
58
65 : std::runtime_error (excCLIDMismatch_format (obj_clid, link_clid))
66{
68}
69
70
71//*************************************************************************
72
73
75std::string
76excInvalidLink_format (CLID clid, const std::string& key, SG::sgkey_t sgkey)
77{
78 return std::format ("SG::ExcInvalidLink: "
79 "Attempt to dereference invalid DataLink / ElementLink "
80 "[{}/{}] ({})",
81 clid, key, sgkey);
82}
83
84
92 const std::string& key,
93 SG::sgkey_t sgkey)
94 : std::runtime_error (excInvalidLink_format (clid, key, sgkey))
95{
97}
98
99
106void throwExcInvalidLink (CLID clid, const std::string& key, SG::sgkey_t sgkey)
107{
108 throw ExcInvalidLink (clid, key, sgkey);
109}
110
111
112//*************************************************************************
113
114
116std::string
117excBadForwardLink_format (size_t index, size_t size, const std::string& name)
118{
119 std::string s = std::format ("SG::ExcBadForwardLink: "
120 "ForwardIndexingPolicy: internal link state of '{}' is invalid", name);
121 if (index != static_cast<size_t>(-1)) {
122 s += std::format (": m_index = {} is >= data container size = {}",
123 index, size);
124 }
125 return s;
126}
127
128
135ExcBadForwardLink::ExcBadForwardLink (size_t index, size_t size, const std::string& name)
136 : std::runtime_error (excBadForwardLink_format (index, size, name))
137{
139}
140
141
148void throwExcBadForwardLink (size_t index, size_t size, const std::string& name)
149{
150 throw ExcBadForwardLink (index, size, name);
151}
152
153
154//*************************************************************************
155
156
162 : std::runtime_error ("SG::ExcElementNotFound: " + where +
163 ": element not found")
164{
166}
167
168
173void throwExcElementNotFound (const char* where)
174{
175 throw ExcElementNotFound (where);
176}
177
178
179//*************************************************************************
180
181
186ExcInvalidIndex::ExcInvalidIndex (const std::string& where)
187 : std::runtime_error ("SG::ExcInvalidIndex: " + where + ": invalid index")
188{
190}
191
192
197void throwExcInvalidIndex (const char* where)
198{
199 throw ExcInvalidIndex (where);
200}
201
202
203//*************************************************************************
204
205
210ExcIndexNotFound::ExcIndexNotFound (const std::string& where)
211 : std::runtime_error ("SG::ExcIndexNotFound: " + where + ": index not found")
212{
214}
215
216
221void throwExcIndexNotFound (const char* where)
222{
223 throw ExcIndexNotFound (where);
224}
225
226
227//*************************************************************************
228
229
234 : std::runtime_error ("SG::ExcIncomparableEL: Attempt to compare an ElementLink that does not have a SG key or index.")
235{
237}
238
239
244{
245 throw ExcIncomparableEL();
246}
247
248
249//*************************************************************************
250
251
256 : std::runtime_error ("SG::ExcBadToTransient: toTransient() called on an already-initialized link.")
257{
259}
260
261
266{
267 throw ExcBadToTransient();
268}
269
270
271//*************************************************************************
272
273
275std::string
276excConstStorable_format (CLID clid, const std::string& key, SG::sgkey_t sgkey)
277{
278 return std::format ("SG::ExcConstStorable: "
279 "Tried to retrieve const storable as a non-const pointer "
280 "[{}/{}] ({})",
281 clid, key, sgkey);
282}
283
284
292 const std::string& key,
293 SG::sgkey_t sgkey)
294 : std::runtime_error (excConstStorable_format (clid, key, sgkey))
295{
297}
298
299
300//*************************************************************************
301
302
304std::string
305excBadThinning_format (CLID clid, const std::string& key, SG::sgkey_t sgkey)
306{
307 return std::format ("SG::ExcBadThinning: Bad thinning request [{}/{}] ({})",
308 clid, key, sgkey);
309}
310
311
319 const std::string& key,
320 SG::sgkey_t sgkey)
321 : std::runtime_error (excBadThinning_format (clid, key, sgkey))
322{
324}
325
326
334 const std::string& key,
335 SG::sgkey_t sgkey)
336{
337 throw ExcBadThinning (clid, key, sgkey);
338}
339
340
341} // 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.
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.
virtual size_t size() const override
Return the number of elements in the store.
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.