ATLAS Offline Software
Loading...
Searching...
No Matches
Control/StoreGate/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
13#include <format>
14
15
16namespace SG {
17
18
23 : std::runtime_error ("SG::ExcNullHandleKey: Attempt to dereference a Read/Write/UpdateHandle with a null key.")
24{
25}
26
27
31[[noreturn]]
33{
34 throw ExcNullHandleKey();
35}
36
37
38//****************************************************************************
39
40
45ExcBadHandleKey::ExcBadHandleKey (const std::string& key)
46 : std::runtime_error ("SG::ExcBadHandleKey: Bad key format for VarHandleKey: `" + key + "'")
47{
48}
49
50
51//****************************************************************************
52
53
59 : std::runtime_error ("SG::ExcForbiddenMethod: Forbidden method called: `" + name + "'")
60{
61}
62
63
64//****************************************************************************
65
66
69 const std::string& sgkey,
70 const std::string& storename)
71
72{
73 return std::format ("SG::ExcHandleInitError: "
74 "Error initializing VarHandle from VarHandleKey: {}+{}[{}]",
75 storename, sgkey, clid);
76}
77
78
86 const std::string& sgkey,
87 const std::string& storename)
88 : std::runtime_error (excHandleInitError_format (clid, sgkey, storename))
89{
90}
91
92
93//****************************************************************************
94
95
97std::string excUninitKey_format (CLID clid,
98 const std::string& sgkey,
99 const std::string& storename,
100 const std::string& holdername,
101 const std::string& htype)
102
103{
104 std::string s =
105 std::format ("SG::ExcUninitKey: "
106 "Error initializing {} from uninitialized {}Key: {}+{}[{}]; "
107 "keys should be initialized in your initialize().",
108 htype, htype, storename, sgkey, clid);
109 if ( holdername.size() )
110 s += std::format (" Key held by {}.", holdername);
111 return s;
112}
113
114
124 const std::string& sgkey,
125 const std::string& storename,
126 const std::string& holdername /*= ""*/,
127 const std::string& htype /*= "VarHandle"*/)
128 : std::runtime_error (excUninitKey_format (clid, sgkey, storename, holdername, htype))
129{
130}
131
132
133//****************************************************************************
134
135
137std::string excConstObject_format (CLID clid,
138 const std::string& sgkey,
139 const std::string& storename)
140
141{
142 return std::format ("SG::ExcConstObject: "
143 "Tried to retrieve non-const pointer to const object via VarHandleKey: {}+{}[{}]",
144 storename, sgkey, clid);
145}
146
147
155 const std::string& sgkey,
156 const std::string& storename)
157 : std::runtime_error (excConstObject_format (clid, sgkey, storename))
158{
159}
160
161
162//****************************************************************************
163
164
167 const std::string& sgkey,
168 const std::string& storename)
169
170{
171 return std::format ("SG::ExcNullWriteHandle: "
172 "Attempt to dereference write handle before record: {}+{}[{}]",
173 storename, sgkey, clid);
174}
175
176
184 const std::string& sgkey,
185 const std::string& storename)
186 : std::runtime_error (excNullWriteHandle_format (clid, sgkey, storename))
187{
188}
189
190
198 const std::string& sgkey,
199 const std::string& storename)
200{
201 throw ExcNullWriteHandle (clid, sgkey, storename);
202}
203
204
205//****************************************************************************
206
207
210 const std::string& sgkey,
211 const std::string& storename)
212
213{
214 return std::format ("SG::ExcNullReadHandle: "
215 "Dereference of read handle failed: {}+{}[{}]",
216 storename, sgkey, clid);
217}
218
219
227 const std::string& sgkey,
228 const std::string& storename)
229 : std::runtime_error (excNullReadHandle_format (clid, sgkey, storename))
230{
231}
232
233
241 const std::string& sgkey,
242 const std::string& storename)
243{
244 throw ExcNullReadHandle (clid, sgkey, storename);
245}
246
247
248//****************************************************************************
249
250
253 const std::string& sgkey,
254 const std::string& storename)
255
256{
257 return std::format ("SG::ExcNullUpdateHandle: "
258 "Dereference of update handle failed: {}+{}[{}]",
259 storename, sgkey, clid);
260}
261
262
270 const std::string& sgkey,
271 const std::string& storename)
272 : std::runtime_error (excNullUpdateHandle_format (clid, sgkey, storename))
273{
274}
275
276
284 const std::string& sgkey,
285 const std::string& storename)
286{
287 throw ExcNullUpdateHandle (clid, sgkey, storename);
288}
289
290
291//****************************************************************************
292
293
296 const std::string& sgkey,
297 const std::string& storename)
298
299{
300 return std::format ("SG::ExcNonConstHandleKey: "
301 "Attempt to get non-const VarHandleKey from non-owning VarHandle: {}+{}[{}]",
302 storename, sgkey, clid);
303}
304
305
313 const std::string& sgkey,
314 const std::string& storename)
315 : std::runtime_error (excNonConstHandleKey_format (clid, sgkey, storename))
316{
317}
318
319
327 const std::string& sgkey,
328 const std::string& storename)
329{
330 throw ExcNonConstHandleKey (clid, sgkey, storename);
331}
332
333
334//****************************************************************************
335
336
341 : std::runtime_error ("SG::ExcInvalidIterator: Attempt to dereference invalid SG::Iterator/SG::ConstIterator")
342{
343}
344
345
346//****************************************************************************
347
348
353 : std::runtime_error ("Initialization of InitializedReadHandleKey failed.")
354{
355}
356
357
358//****************************************************************************
359
360
362std::string excBadContext_format (const EventContext& ctx,
363 const std::string& key)
364
365{
366 return std::format ("SG::ExcBadContext: "
367 "Bad EventContext extension while building ReadCondHandle. "
368 "The EventContext extension is not {} for key {}.",
369 (ctx.hasExtension() ? "of type Atlas::ExtendedEventContext" : "set"),
370 key);
371}
372
373
379ExcBadContext::ExcBadContext (const EventContext& ctx, const std::string& key)
380 : std::runtime_error (excBadContext_format (ctx, key))
381{
382}
383
384
385//****************************************************************************
386
387
389std::string excNoCondCont_format (const std::string& key,
390 const std::string& why)
391
392{
393 return std::format ("SG::ExcNoCondCont: "
394 "Can't retrieve CondCont from ReadCondHandle for key {}. {}",
395 key, why);
396}
397
398
404ExcNoCondCont::ExcNoCondCont (const std::string& key, const std::string& why)
405 : std::runtime_error (excNoCondCont_format (key, why))
406{
407}
408
409
410//****************************************************************************
411
412
417 : std::runtime_error ("SG::ExcBadReadCondHandleInit: ReadCondHandle didn't initialize in getRange().")
418{
419}
420
421
422//****************************************************************************
423
424
429 : std::runtime_error ("SG::ExcBadReadCondHandleInit: Range not set in ReadCondHandle::getRange().")
430{
431}
432
433
434//****************************************************************************
435
436
438std::string excBadDecorElement_format (Gaudi::DataHandle::Mode mode,
439 CLID clid,
440 const std::string& decorKey)
441{
442 std::string modestr = "???";
443 if (mode == Gaudi::DataHandle::Writer)
444 modestr = "Write";
445 else if (mode == Gaudi::DataHandle::Reader)
446 modestr = "Read";
447 return std::format ("SG::ExcBadDecorElement: "
448 "{}DecorHandle {}[{}]"
449 " given an element not in the requested container.",
450 modestr, decorKey, clid);
451}
452
453
460ExcBadDecorElement::ExcBadDecorElement (Gaudi::DataHandle::Mode mode,
461 CLID clid,
462 const std::string& decorKey)
463 : std::runtime_error (excBadDecorElement_format (mode, clid, decorKey))
464{
465}
466
467
471[[noreturn]]
472void throwExcBadDecorElement (Gaudi::DataHandle::Mode mode,
473 CLID clid,
474 const std::string& decorKey)
475{
476 throw SG::ExcBadDecorElement (mode, clid, decorKey);
477}
478
479
480} // namespace SG
Exceptions that can be thrown from StoreGate.
uint32_t CLID
The Class ID type.
ExcBadContext(const EventContext &ctx, const std::string &key)
Constructor.
Exception — DecorHandle given an element not in the requested container.
ExcBadDecorElement(Gaudi::DataHandle::Mode mode, CLID clid, const std::string &decorKey)
Constructor.
ExcBadHandleKey(const std::string &key)
Constructor.
ExcConstObject(CLID clid, const std::string &sgkey, const std::string &storename)
Constructor.
ExcForbiddenMethod(const std::string &name)
Constructor.
ExcHandleInitError(CLID clid, const std::string &sgkey, const std::string &storename)
Constructor.
ExcNoCondCont(const std::string &key, const std::string &why)
Constructor.
Exception — Attempt to get non-const VarHandleKey from non-owning VarHandle.
ExcNonConstHandleKey(CLID clid, const std::string &sgkey, const std::string &storename)
Constructor.
Exception — Attempt to dereference a Read/Write/UpdateHandle with a null key.
Exception — Deference of read handle failed.
ExcNullReadHandle(CLID clid, const std::string &sgkey, const std::string &storename)
Constructor.
Exception — Deference of update handle failed.
ExcNullUpdateHandle(CLID clid, const std::string &sgkey, const std::string &storename)
Constructor.
Exception — Attempt to dereference write handle before record.
ExcNullWriteHandle(CLID clid, const std::string &sgkey, const std::string &storename)
Constructor.
ExcUninitKey(CLID clid, const std::string &sgkey, const std::string &storename, const std::string &holdername="", const std::string &htype="VarHandle")
Constructor.
Forward declaration.
std::string excHandleInitError_format(CLID clid, const std::string &sgkey, const std::string &storename)
Helper: format exception error string.
std::string excNonConstHandleKey_format(CLID clid, const std::string &sgkey, const std::string &storename)
Helper: format exception error string.
void throwExcNullUpdateHandle(CLID clid, const std::string &sgkey, const std::string &storename)
Throw a SG::ExcNullUpdateHandle exception.
void throwExcBadDecorElement(Gaudi::DataHandle::Mode mode, CLID clid, const std::string &decorKey)
Throw a SG::ExcBadDecorElement exception.
std::string excBadDecorElement_format(Gaudi::DataHandle::Mode mode, CLID clid, const std::string &decorKey)
Helper: format exception error string.
void throwExcNullHandleKey()
Throw a SG::ExcNullHandleKey exception.
std::string excNullUpdateHandle_format(CLID clid, const std::string &sgkey, const std::string &storename)
Helper: format exception error string.
void throwExcNonConstHandleKey(CLID clid, const std::string &sgkey, const std::string &storename)
Throw a SG::ExcNonConstHandleKey exception.
void throwExcNullReadHandle(CLID clid, const std::string &sgkey, const std::string &storename)
Throw a SG::ExcNullReadHandle exception.
std::string excNullWriteHandle_format(CLID clid, const std::string &sgkey, const std::string &storename)
Helper: format exception error string.
std::string excBadContext_format(const EventContext &ctx, const std::string &key)
Helper: format exception error string.
std::string excUninitKey_format(CLID clid, const std::string &sgkey, const std::string &storename, const std::string &holdername, const std::string &htype)
Helper: format exception error string.
std::string excNullReadHandle_format(CLID clid, const std::string &sgkey, const std::string &storename)
Helper: format exception error string.
std::string excConstObject_format(CLID clid, const std::string &sgkey, const std::string &storename)
Helper: format exception error string.
void throwExcNullWriteHandle(CLID clid, const std::string &sgkey, const std::string &storename)
Throw a SG::ExcNullWriteHandle exception.
std::string excNoCondCont_format(const std::string &key, const std::string &why)
Helper: format exception error string.
STL namespace.