ATLAS Offline Software
Loading...
Searching...
No Matches
Control/StoreGate/src/exceptions.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
10
11
13#include <sstream>
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 std::ostringstream os;
74 os << "SG::ExcHandleInitError: "
75 << "Error initializing VarHandle from VarHandleKey: "
76 << storename << "+" << sgkey << "[" << clid << "]";
77 return os.str();
78}
79
80
88 const std::string& sgkey,
89 const std::string& storename)
90 : std::runtime_error (excHandleInitError_format (clid, sgkey, storename))
91{
92}
93
94
95//****************************************************************************
96
97
99std::string excUninitKey_format (CLID clid,
100 const std::string& sgkey,
101 const std::string& storename,
102 const std::string& holdername,
103 const std::string& htype)
104
105{
106 std::ostringstream os;
107 os << "SG::ExcUninitKey: "
108 << "Error initializing " << htype << " from uninitialized " << htype << "Key: "
109 << storename << "+" << sgkey << "[" << clid << "]; "
110 << "keys should be initialized in your initialize().";
111 if ( holdername.size() ) os << " Key held by " << holdername << ".";
112 return os.str();
113}
114
115
125 const std::string& sgkey,
126 const std::string& storename,
127 const std::string& holdername /*= ""*/,
128 const std::string& htype /*= "VarHandle"*/)
129 : std::runtime_error (excUninitKey_format (clid, sgkey, storename, holdername, htype))
130{
131}
132
133
134//****************************************************************************
135
136
138std::string excConstObject_format (CLID clid,
139 const std::string& sgkey,
140 const std::string& storename)
141
142{
143 std::ostringstream os;
144 os << "SG::ExcConstObject: "
145 << "Tried to retrieve non-const pointer to const object via VarHandleKey: "
146 << storename << "+" << sgkey << "[" << clid << "]";
147 return os.str();
148}
149
150
158 const std::string& sgkey,
159 const std::string& storename)
160 : std::runtime_error (excConstObject_format (clid, sgkey, storename))
161{
162}
163
164
165//****************************************************************************
166
167
170 const std::string& sgkey,
171 const std::string& storename)
172
173{
174 std::ostringstream os;
175 os << "SG::ExcNullWriteHandle: "
176 << "Attempt to dereference write handle before record: "
177 << storename << "+" << sgkey << "[" << clid << "]";
178 return os.str();
179}
180
181
189 const std::string& sgkey,
190 const std::string& storename)
191 : std::runtime_error (excNullWriteHandle_format (clid, sgkey, storename))
192{
193}
194
195
203 const std::string& sgkey,
204 const std::string& storename)
205{
206 throw ExcNullWriteHandle (clid, sgkey, storename);
207}
208
209
210//****************************************************************************
211
212
215 const std::string& sgkey,
216 const std::string& storename)
217
218{
219 std::ostringstream os;
220 os << "SG::ExcNullReadHandle: "
221 << "Dereference of read handle failed: "
222 << storename << "+" << sgkey << "[" << clid << "]";
223 return os.str();
224}
225
226
234 const std::string& sgkey,
235 const std::string& storename)
236 : std::runtime_error (excNullReadHandle_format (clid, sgkey, storename))
237{
238}
239
240
248 const std::string& sgkey,
249 const std::string& storename)
250{
251 throw ExcNullReadHandle (clid, sgkey, storename);
252}
253
254
255//****************************************************************************
256
257
260 const std::string& sgkey,
261 const std::string& storename)
262
263{
264 std::ostringstream os;
265 os << "SG::ExcNullUpdateHandle: "
266 << "Dereference of update handle failed: "
267 << storename << "+" << sgkey << "[" << clid << "]";
268 return os.str();
269}
270
271
279 const std::string& sgkey,
280 const std::string& storename)
281 : std::runtime_error (excNullUpdateHandle_format (clid, sgkey, storename))
282{
283}
284
285
293 const std::string& sgkey,
294 const std::string& storename)
295{
296 throw ExcNullUpdateHandle (clid, sgkey, storename);
297}
298
299
300//****************************************************************************
301
302
305 const std::string& sgkey,
306 const std::string& storename)
307
308{
309 std::ostringstream os;
310 os << "SG::ExcNonConstHandleKey: "
311 << "Attempt to get non-const VarHandleKey from non-owning VarHandle: "
312 << storename << "+" << sgkey << "[" << clid << "]";
313 return os.str();
314}
315
316
324 const std::string& sgkey,
325 const std::string& storename)
326 : std::runtime_error (excNonConstHandleKey_format (clid, sgkey, storename))
327{
328}
329
330
338 const std::string& sgkey,
339 const std::string& storename)
340{
341 throw ExcNonConstHandleKey (clid, sgkey, storename);
342}
343
344
345//****************************************************************************
346
347
352 : std::runtime_error ("SG::ExcInvalidIterator: Attempt to dereference invalid SG::Iterator/SG::ConstIterator")
353{
354}
355
356
357//****************************************************************************
358
359
364 : std::runtime_error ("Initialization of InitializedReadHandleKey failed.")
365{
366}
367
368
369//****************************************************************************
370
371
373std::string excBadContext_format (const EventContext& ctx,
374 const std::string& key)
375
376{
377 std::ostringstream os;
378 os << "SG::ExcBadContext: Bad EventContext extension while building ReadCondHandle. "
379 << "The EventContext extension is not "
380 << (ctx.hasExtension() ? "of type Atlas::ExtendedEventContext" : "set")
381 << " for key " << key << ".";
382 return os.str();
383}
384
385
391ExcBadContext::ExcBadContext (const EventContext& ctx, const std::string& key)
393{
394}
395
396
397//****************************************************************************
398
399
401std::string excNoCondCont_format (const std::string& key,
402 const std::string& why)
403
404{
405 std::ostringstream os;
406 os << "SG::ExcNoCondCont: Can't retrieve CondCont from ReadCondHandle for key "
407 << key << ". " << why;
408 return os.str();
409}
410
411
417ExcNoCondCont::ExcNoCondCont (const std::string& key, const std::string& why)
419{
420}
421
422
423//****************************************************************************
424
425
430 : std::runtime_error ("SG::ExcBadReadCondHandleInit: ReadCondHandle didn't initialize in getRange().")
431{
432}
433
434
435//****************************************************************************
436
437
442 : std::runtime_error ("SG::ExcBadReadCondHandleInit: Range not set in ReadCondHandle::getRange().")
443{
444}
445
446
447//****************************************************************************
448
449
451std::string excBadDecorElement_format (Gaudi::DataHandle::Mode mode,
452 CLID clid,
453 const std::string& decorKey)
454{
455 std::ostringstream os;
456 os << "SG::ExcBadDecorElement: ";
457 if (mode == Gaudi::DataHandle::Writer)
458 os << "Write";
459 else if (mode == Gaudi::DataHandle::Reader)
460 os << "Read";
461 else
462 os << "???";
463 os << "DecorHandle " << decorKey
464 << "[" << clid << "]"
465 << " given an element not in the requested container.";
466 return os.str();
467}
468
469
476ExcBadDecorElement::ExcBadDecorElement (Gaudi::DataHandle::Mode mode,
477 CLID clid,
478 const std::string& decorKey)
479 : std::runtime_error (excBadDecorElement_format (mode, clid, decorKey))
480{
481}
482
483
487[[noreturn]]
488void throwExcBadDecorElement (Gaudi::DataHandle::Mode mode,
489 CLID clid,
490 const std::string& decorKey)
491{
492 throw SG::ExcBadDecorElement (mode, clid, decorKey);
493}
494
495
496} // 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.
STL class.
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.