ATLAS Offline Software
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 */
12 #include "StoreGate/exceptions.h"
13 #include <sstream>
14 
15 
16 namespace 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 
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 
68 std::string excHandleInitError_format (CLID clid,
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 
99 std::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 
138 std::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 
169 std::string excNullWriteHandle_format (CLID clid,
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 
214 std::string excNullReadHandle_format (CLID clid,
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 
373 std::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 
391 ExcBadContext::ExcBadContext (const EventContext& ctx, const std::string& key)
392  : std::runtime_error (excBadContext_format (ctx, key))
393 {
394 }
395 
396 
397 //****************************************************************************
398 
399 
401 std::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 
417 ExcNoCondCont::ExcNoCondCont (const std::string& key, const std::string& why)
418  : std::runtime_error (excNoCondCont_format (key, 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 
452  CLID clid,
453  const std::string& decorKey)
454 {
455  std::ostringstream os;
456  os << "SG::ExcBadDecorElement: ";
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 
477  CLID clid,
478  const std::string& decorKey)
479  : std::runtime_error (excBadDecorElement_format (mode, clid, decorKey))
480 {
481 }
482 
483 
487 [[noreturn]]
489  CLID clid,
490  const std::string& decorKey)
491 {
492  throw SG::ExcBadDecorElement (mode, clid, decorKey);
493 }
494 
495 
496 } // namespace SG
common.sgkey
def sgkey(tool)
Definition: common.py:1028
SG::ExcNullHandleKey
Exception — Attempt to dereference a Read/Write/UpdateHandle with a null key.
Definition: Control/StoreGate/StoreGate/exceptions.h:38
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
SG::ExcNullUpdateHandle::ExcNullUpdateHandle
ExcNullUpdateHandle(CLID clid, const std::string &sgkey, const std::string &storename)
Constructor.
Definition: Control/StoreGate/src/exceptions.cxx:278
SG::ExcBadDecorElement
Exception — DecorHandle given an element not in the requested container.
Definition: Control/StoreGate/StoreGate/exceptions.h:376
SG::throwExcNullWriteHandle
void throwExcNullWriteHandle(CLID clid, const std::string &sgkey, const std::string &storename)
Throw a SG::ExcNullWriteHandle exception.
Definition: Control/StoreGate/src/exceptions.cxx:202
SG::excNullWriteHandle_format
std::string excNullWriteHandle_format(CLID clid, const std::string &sgkey, const std::string &storename)
Helper: format exception error string.
Definition: Control/StoreGate/src/exceptions.cxx:169
SG::ExcConstObject::ExcConstObject
ExcConstObject(CLID clid, const std::string &sgkey, const std::string &storename)
Constructor.
Definition: Control/StoreGate/src/exceptions.cxx:157
SG::ExcHandleInitError::ExcHandleInitError
ExcHandleInitError(CLID clid, const std::string &sgkey, const std::string &storename)
Constructor.
Definition: Control/StoreGate/src/exceptions.cxx:87
SG::ExcBadHandleKey::ExcBadHandleKey
ExcBadHandleKey(const std::string &key)
Constructor.
Definition: Control/StoreGate/src/exceptions.cxx:45
SG::ExcBadInitializedReadHandleKey::ExcBadInitializedReadHandleKey
ExcBadInitializedReadHandleKey()
Constructor.
Definition: Control/StoreGate/src/exceptions.cxx:363
SG::ExcNullReadHandle
Exception — Deference of read handle failed.
Definition: Control/StoreGate/StoreGate/exceptions.h:184
SG::excBadContext_format
std::string excBadContext_format(const EventContext &ctx, const std::string &key)
Helper: format exception error string.
Definition: Control/StoreGate/src/exceptions.cxx:373
IDTPMcnv.htype
htype
Definition: IDTPMcnv.py:27
SG::ExcNullWriteHandle::ExcNullWriteHandle
ExcNullWriteHandle(CLID clid, const std::string &sgkey, const std::string &storename)
Constructor.
Definition: Control/StoreGate/src/exceptions.cxx:188
SG::ExcBadContext::ExcBadContext
ExcBadContext(const EventContext &ctx, const std::string &key)
Constructor.
Definition: Control/StoreGate/src/exceptions.cxx:391
SG::ExcNonConstHandleKey::ExcNonConstHandleKey
ExcNonConstHandleKey(CLID clid, const std::string &sgkey, const std::string &storename)
Constructor.
Definition: Control/StoreGate/src/exceptions.cxx:323
SG::excHandleInitError_format
std::string excHandleInitError_format(CLID clid, const std::string &sgkey, const std::string &storename)
Helper: format exception error string.
Definition: Control/StoreGate/src/exceptions.cxx:68
SG::excConstObject_format
std::string excConstObject_format(CLID clid, const std::string &sgkey, const std::string &storename)
Helper: format exception error string.
Definition: Control/StoreGate/src/exceptions.cxx:138
exceptions.h
Exceptions that can be thrown from StoreGate.
SG::ExcNonConstHandleKey
Exception — Attempt to get non-const VarHandleKey from non-owning VarHandle.
Definition: Control/StoreGate/StoreGate/exceptions.h:251
SG::throwExcNullUpdateHandle
void throwExcNullUpdateHandle(CLID clid, const std::string &sgkey, const std::string &storename)
Throw a SG::ExcNullUpdateHandle exception.
Definition: Control/StoreGate/src/exceptions.cxx:292
SG::excBadDecorElement_format
std::string excBadDecorElement_format(Gaudi::DataHandle::Mode mode, CLID clid, const std::string &decorKey)
Helper: format exception error string.
Definition: Control/StoreGate/src/exceptions.cxx:451
SG::throwExcNullHandleKey
void throwExcNullHandleKey()
Throw a SG::ExcNullHandleKey exception.
Definition: Control/StoreGate/src/exceptions.cxx:32
LHEF::Reader
Pythia8::Reader Reader
Definition: Prophecy4fMerger.cxx:11
SG::ExcForbiddenMethod::ExcForbiddenMethod
ExcForbiddenMethod(const std::string &name)
Constructor.
Definition: Control/StoreGate/src/exceptions.cxx:58
Preparation.mode
mode
Definition: Preparation.py:94
SG::ExcNoCondCont::ExcNoCondCont
ExcNoCondCont(const std::string &key, const std::string &why)
Constructor.
Definition: Control/StoreGate/src/exceptions.cxx:417
SG::ExcNullHandleKey::ExcNullHandleKey
ExcNullHandleKey()
Constructor.
Definition: Control/StoreGate/src/exceptions.cxx:22
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::ExcBadDecorElement::ExcBadDecorElement
ExcBadDecorElement(Gaudi::DataHandle::Mode mode, CLID clid, const std::string &decorKey)
Constructor.
Definition: Control/StoreGate/src/exceptions.cxx:476
SG::throwExcNullReadHandle
void throwExcNullReadHandle(CLID clid, const std::string &sgkey, const std::string &storename)
Throw a SG::ExcNullReadHandle exception.
Definition: Control/StoreGate/src/exceptions.cxx:247
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
EventContainers::Mode
Mode
Definition: IdentifiableContainerBase.h:13
SG::ExcNullReadHandle::ExcNullReadHandle
ExcNullReadHandle(CLID clid, const std::string &sgkey, const std::string &storename)
Constructor.
Definition: Control/StoreGate/src/exceptions.cxx:233
SG::excNullUpdateHandle_format
std::string excNullUpdateHandle_format(CLID clid, const std::string &sgkey, const std::string &storename)
Helper: format exception error string.
Definition: Control/StoreGate/src/exceptions.cxx:259
SG::throwExcNonConstHandleKey
void throwExcNonConstHandleKey(CLID clid, const std::string &sgkey, const std::string &storename)
Throw a SG::ExcNonConstHandleKey exception.
Definition: Control/StoreGate/src/exceptions.cxx:337
SG::excNullReadHandle_format
std::string excNullReadHandle_format(CLID clid, const std::string &sgkey, const std::string &storename)
Helper: format exception error string.
Definition: Control/StoreGate/src/exceptions.cxx:214
SG::excNoCondCont_format
std::string excNoCondCont_format(const std::string &key, const std::string &why)
Helper: format exception error string.
Definition: Control/StoreGate/src/exceptions.cxx:401
SG::ExcNoRange::ExcNoRange
ExcNoRange()
Constructor.
Definition: Control/StoreGate/src/exceptions.cxx:441
SG::excUninitKey_format
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.
Definition: Control/StoreGate/src/exceptions.cxx:99
SG::ExcBadReadCondHandleInit::ExcBadReadCondHandleInit
ExcBadReadCondHandleInit()
Constructor.
Definition: Control/StoreGate/src/exceptions.cxx:429
SG::ExcInvalidIterator::ExcInvalidIterator
ExcInvalidIterator()
Constructor.
Definition: Control/StoreGate/src/exceptions.cxx:351
SG::throwExcBadDecorElement
void throwExcBadDecorElement(Gaudi::DataHandle::Mode mode, CLID clid, const std::string &decorKey)
Throw a SG::ExcBadDecorElement exception.
Definition: Control/StoreGate/src/exceptions.cxx:488
SG::ExcUninitKey::ExcUninitKey
ExcUninitKey(CLID clid, const std::string &sgkey, const std::string &storename, const std::string &holdername="", const std::string &htype="VarHandle")
Constructor.
Definition: Control/StoreGate/src/exceptions.cxx:124
SG::ExcNullWriteHandle
Exception — Attempt to dereference write handle before record.
Definition: Control/StoreGate/StoreGate/exceptions.h:153
LHEF::Writer
Pythia8::Writer Writer
Definition: Prophecy4fMerger.cxx:12
SG::excNonConstHandleKey_format
std::string excNonConstHandleKey_format(CLID clid, const std::string &sgkey, const std::string &storename)
Helper: format exception error string.
Definition: Control/StoreGate/src/exceptions.cxx:304
SG::ExcNullUpdateHandle
Exception — Deference of update handle failed.
Definition: Control/StoreGate/StoreGate/exceptions.h:215
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37