ATLAS Offline Software
Control/AthContainers/Root/exceptions.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
15 #include <sstream>
16 
17 
18 namespace SG {
19 
20 
22 std::string excFormatName (SG::auxid_t auxid)
23 {
24  std::ostringstream os;
25  if (auxid != null_auxid) {
27  os << "`" << r.getClassName (auxid);
28  if (!os.str().empty())
29  os << "::";
30  os << r.getName (auxid);
31  os << "' (" << auxid << ")";
32  }
33  else {
34  os << "(null)";
35  }
36  return os.str();
37 }
38 
39 
40 //*************************************************************************
41 
42 
44 std::string excNoAuxStore_format (SG::auxid_t auxid)
45 {
46  std::ostringstream os;
47  os << "SG::ExcNoAuxStore: "
48  << "Requested aux data item "
49  << excFormatName (auxid)
50  << " but there is no associated aux data store.";
51  return os.str();
52 }
53 
54 
56 std::string excNoAuxStore_format (const char* op)
57 {
58  std::ostringstream os;
59  os << "SG::ExcNoAuxStore: "
60  << "Operation attempted on container with no associated aux data store: ";
61  os << op;
62  return os.str();
63 }
64 
65 
71  : std::runtime_error (excNoAuxStore_format (auxid))
72 {
73 }
74 
75 
81  : std::runtime_error (excNoAuxStore_format (op))
82 {
83 }
84 
85 
86 //*************************************************************************
87 
88 
90 std::string excBadAuxVar_format (SG::auxid_t auxid)
91 {
92  std::ostringstream os;
93  os << "SG::ExcBadAuxVar: "
94  << "Attempt to retrieve nonexistent aux data item "
95  << excFormatName (auxid)
96  << ".";
97  return os.str();
98 }
99 
100 
106  : std::runtime_error (excBadAuxVar_format (auxid))
107 {
108 }
109 
110 
111 //*************************************************************************
112 
113 
115 std::string excConstAuxData_format (const std::string& op, SG::auxid_t auxid)
116 {
117  std::ostringstream os;
118  os << "SG::ExcConstAuxData: "
119  << "Non-const operation `" << op << "' performed on const aux data "
120  << excFormatName (auxid)
121  << ".";
122  return os.str();
123 }
124 
125 
131 ExcConstAuxData::ExcConstAuxData (const std::string& op, SG::auxid_t auxid)
132  : std::runtime_error (excConstAuxData_format (op, auxid))
133 {
134 }
135 
136 
137 //*************************************************************************
138 
139 
144  : std::runtime_error
145  ("SG::ExcUntrackedSetStore: "
146  "Attempt to set aux data store on container that doesn't track indices, "
147  "or disable index tracking for a container with aux data.")
148 {
149 }
150 
151 
152 //*************************************************************************
153 
154 
160  : std::runtime_error ("SG::ExcBadPrivateStore: "
161  "Bad use of private store: " + op)
162 {
163 }
164 
165 
166 //*************************************************************************
167 
168 
171  const std::type_info& new_type,
172  const std::type_info& old_type,
173  const std::string& new_alloc_type,
174  const std::string& old_alloc_type)
175 {
176  std::ostringstream os;
177  os << "SG::ExcAuxTypeMismatch: "
178  << "Type mismatch for aux variable "
179  << excFormatName (auxid)
180  << "; old type is " << AthContainers_detail::typeinfoName (old_type)
181  << " new type is " << AthContainers_detail::typeinfoName (new_type);
182  if (old_alloc_type != new_alloc_type)
183  {
184  os << ". Old allocator type is " << old_alloc_type
185  << " new allocator type is " << new_alloc_type;
186  }
187  return os.str();
188 }
189 
190 
200  const std::type_info& new_type,
201  const std::type_info& old_type,
202  const std::string& new_alloc_type,
203  const std::string& old_alloc_type)
204  : std::runtime_error (excAuxTypeMismatch_format (auxid,
205  new_type, old_type,
206  new_alloc_type,
207  old_alloc_type))
208 {
209 }
210 
211 
212 //*************************************************************************
213 
214 
216 std::string excInsertionInBaseClass_format (const char* op,
217  const std::type_info& base_type,
218  const std::type_info& complete_type)
219 {
220  std::ostringstream os;
221  os << "SG::ExcInsertionInBaseClass: "
222  << "Attempted to do " << op
223  << " on a " << AthContainers_detail::typeinfoName (base_type)
224  << " base class of " << AthContainers_detail::typeinfoName (complete_type)
225  << "; can only be done on the most-derived class.";
226  return os.str();
227 }
228 
229 
237  (const char* op,
238  const std::type_info& base_type,
239  const std::type_info& complete_type)
240  : std::runtime_error (excInsertionInBaseClass_format (op,
241  base_type,
242  complete_type))
243 {
244 }
245 
246 
247 //*************************************************************************
248 
249 
252 {
253  std::ostringstream os;
254  os << "SG::ExcStoreLocked: "
255  << "Attempted to modify auxiliary data in a locked store: ";
256  os << excFormatName (auxid);
257  return os.str();
258 }
259 
260 
262 std::string excStoreLocked_format (const char* op)
263 {
264  std::ostringstream os;
265  os << "SG::ExcStoreLocked: "
266  << "Attempted to modify auxiliary data in a locked store: ";
267  os << op;
268  return os.str();
269 }
270 
271 
277  : std::runtime_error (excStoreLocked_format (auxid))
278 {
279 }
280 
281 
287  : std::runtime_error (excStoreLocked_format (op))
288 {
289 }
290 
291 
292 //*************************************************************************
293 
294 
299  : std::runtime_error ("SG::ExcNonowningContainer: Attempted to insert a unique_ptr to a non-owning container.")
300 {
301 }
302 
303 
308 {
309  throw ExcNonowningContainer();
310 }
311 
312 
313 //*************************************************************************
314 
315 
317 std::string excUnknownAuxItem_format (const std::string& name,
318  const std::string& clsname,
319  const std::type_info* typ)
320 {
321  std::ostringstream os;
322  os << "SG::ExcUnknownAuxItem: "
323  << "Unknown aux data item ";
324  if (!clsname.empty())
325  os << clsname << "::";
326  os << name;
327  if (typ)
328  os << " (of type " << AthContainers_detail::typeinfoName (*typ) << ")";
329  return os.str();
330 }
331 
332 
340  const std::string& clsname /*= ""*/,
341  const std::type_info* typ /*= 0*/)
342  : std::runtime_error (excUnknownAuxItem_format (name, clsname, typ))
343 {
344 }
345 
346 
353 void throwExcUnknownAuxItem (const std::string& name,
354  const std::string& clsname /*= ""*/,
355  const std::type_info* typ /*= 0*/)
356 {
357  throw ExcUnknownAuxItem (name, clsname, typ);
358 }
359 
360 
361 //*************************************************************************
362 
363 
365 std::string excDVToELV_format (const std::string& detail)
366 {
367  std::ostringstream os;
368  os << "SG::ExcDVToELV: "
369  << "Can't convert DataVector to vector of ElementLinks: "
370  << detail;
371  return os.str();
372 }
373 
374 
379 ExcDVToELV::ExcDVToELV (const std::string& detail)
380  : std::runtime_error (excDVToELV_format (detail))
381 {
382 }
383 
384 
385 //*************************************************************************
386 
387 
392  : std::runtime_error ("ViewVector not in view mode.")
393 {
394 }
395 
396 
401 {
402  throw ExcViewVectorNotView();
403 }
404 
405 
406 //*************************************************************************
407 
408 
413  : std::runtime_error ("ViewVector " + AthContainers_detail::typeinfoName(ti) +
414  "was used in a context that requires a CLID, "
415  "but no CLID was available. Make sure a "
416  "VIEWVECTOR_CLASS_DEF declaration exists for the class "
417  "in a library that has been loaded.")
418 {
419 }
420 
421 
425 void throwExcMissingViewVectorCLID (const std::type_info& ti)
426 {
427  throw ExcMissingViewVectorCLID (ti);
428 }
429 
430 
431 //*************************************************************************
432 
433 
437 ExcMissingBaseInfo::ExcMissingBaseInfo (const std::type_info& ti)
438  : std::runtime_error ("Missing BaseInfo for " +
439  AthContainers_detail::typeinfoName(ti))
440 {
441 }
442 
443 
447 void throwExcMissingBaseInfo (const std::type_info& ti)
448 {
449  throw ExcMissingBaseInfo (ti);
450 }
451 
452 
453 //*************************************************************************
454 
455 
460  : std::runtime_error ("Ownership mismatch for insertMove.")
461 {
462 }
463 
464 
465 //*************************************************************************
466 
467 
470 {
471  std::string out;
473  out = "atomic";
475  if (!out.empty()) out += " ";
476  out = "linked";
477  }
478 
479  return "[" + out + "]";
480 }
481 
482 
485  const std::type_info& type,
486  SG::AuxVarFlags existing_flags,
487  SG::AuxVarFlags requested_flags)
488 {
489  std::ostringstream os;
490  os << "SG::ExcFlagMismatch: "
491  << "Flag mismatch for aux variable "
492  << excFormatName (auxid)
493  << " of type " << AthContainers_detail::typeinfoName (type)
494  << " between existing " << excFormatFlags (existing_flags)
495  << " and requested " << excFormatFlags (requested_flags) << " flags. "
496  << "This may occur as a result of not using AtomicDecorator to access an atomic variable.";
497  return os.str();
498 }
499 
500 
509  const std::type_info& type,
510  SG::AuxVarFlags existing_flags,
511  SG::AuxVarFlags requested_flags)
512  : std::runtime_error (excFlagMismatch_format (auxid, type, existing_flags, requested_flags))
513 {
514 }
515 
516 
517 //*************************************************************************
518 
519 
522  const std::type_info& type,
523  SG::auxid_t existing_linked_id,
524  SG::auxid_t requested_linked_id)
525 {
526  std::ostringstream os;
527  os << "SG::ExcLinkMismatch: "
528  << "Linked variable mismatch for aux variable "
529  << excFormatName (auxid)
530  << " of type " << AthContainers_detail::typeinfoName (type)
531  << " between existing " << excFormatName (existing_linked_id)
532  << " and requested " << excFormatName (requested_linked_id) << " linked variables.";
533  return os.str();
534 }
535 
536 
545  const std::type_info& type,
546  SG::auxid_t existing_linked_id,
547  SG::auxid_t requested_linked_id)
548  : std::runtime_error (excLinkMismatch_format (auxid, type,
549  existing_linked_id, requested_linked_id))
550 {
551 }
552 
553 
554 //*************************************************************************
555 
556 
559  const std::type_info& type)
560 {
561  std::ostringstream os;
562  os << "SG::ExcNoLinkedVar: "
563  << "Linked variable not found for aux variable "
564  << excFormatName (auxid)
565  << " of type " << AthContainers_detail::typeinfoName (type);
566  return os.str();
567 }
568 
569 
576  const std::type_info& type)
577  : std::runtime_error (excNoLinkedVar_format (auxid, type))
578 {
579 }
580 
581 
582 //*************************************************************************
583 
584 
586 std::string excInvalidThinningTarget_format (unsigned int clid,
587  const std::string& key)
588 {
589  std::ostringstream os;
590  os << "SG::ExcInvalidThinningTarget: "
591  << "ThinningHandle target does not exist: "
592  << clid << "/" << key;
593  return os.str();
594 }
595 
596 
603  const std::string& key)
604  : std::runtime_error (excInvalidThinningTarget_format (clid, key))
605 {
606 }
607 
608 
609 //*************************************************************************
610 
611 
616  : std::runtime_error ("SG::ExcBadIterSwap: Attempt to swap between containers with inconsistent ownership.")
617 {
618 }
619 
620 
621 //*************************************************************************
622 
623 
628  : std::runtime_error ("SG::ExcAllocOwnership: Bad allocation ownership.")
629 {
630 }
631 
632 
637 {
638  throw ExcAllocOwnership();
639 }
640 
641 
642 //*************************************************************************
643 
644 
646 std::string excBadVarName_format (const std::string& name)
647 {
648  std::ostringstream os;
649  os << "SG::ExcBadVarName: "
650  << "Bad name for auxiliary variable `" << name << "'. "
651  << "Variable and class names must consist of only digits, letters, "
652  << "and underscores, and cannot start with a digit. "
653  << "Variable names may not be empty, but class names may be.";
654  return os.str();
655 }
656 
657 
662 ExcBadVarName::ExcBadVarName (const std::string& name)
663  : std::runtime_error (excBadVarName_format (name))
664 {
665 }
666 
667 
668 } // namespace SG
SG::excInsertionInBaseClass_format
std::string excInsertionInBaseClass_format(const char *op, const std::type_info &base_type, const std::type_info &complete_type)
Helper: format exception error string.
Definition: Control/AthContainers/Root/exceptions.cxx:216
beamspotman.r
def r
Definition: beamspotman.py:676
SG::ExcInsertMoveOwnershipMismatch::ExcInsertMoveOwnershipMismatch
ExcInsertMoveOwnershipMismatch()
Constructor.
Definition: Control/AthContainers/Root/exceptions.cxx:459
SG::excFlagMismatch_format
std::string excFlagMismatch_format(SG::auxid_t auxid, const std::type_info &type, SG::AuxVarFlags existing_flags, SG::AuxVarFlags requested_flags)
Helper: format exception error string.
Definition: Control/AthContainers/Root/exceptions.cxx:484
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
SG::ExcAuxTypeMismatch::ExcAuxTypeMismatch
ExcAuxTypeMismatch(SG::auxid_t auxid, const std::type_info &new_type, const std::type_info &old_type, const std::string &new_alloc_type, const std::string &old_alloc_type)
Constructor.
Definition: Control/AthContainers/Root/exceptions.cxx:199
SG::AuxTypeRegistry::instance
static AuxTypeRegistry & instance()
Return the singleton registry instance.
Definition: AuxTypeRegistry.cxx:49
SG::ExcMissingViewVectorCLID::ExcMissingViewVectorCLID
ExcMissingViewVectorCLID(const std::type_info &ti)
Constructor.
Definition: Control/AthContainers/Root/exceptions.cxx:412
SG::ExcBadAuxVar::ExcBadAuxVar
ExcBadAuxVar(SG::auxid_t auxid)
Constructor.
Definition: Control/AthContainers/Root/exceptions.cxx:105
SG::excStoreLocked_format
std::string excStoreLocked_format(SG::auxid_t auxid)
Helper: format exception error string.
Definition: Control/AthContainers/Root/exceptions.cxx:251
AthenaPoolTestRead.flags
flags
Definition: AthenaPoolTestRead.py:8
SG::ExcViewVectorNotView
Exception — ViewVector not in view mode.
Definition: Control/AthContainers/AthContainers/exceptions.h:285
exceptions.h
Exceptions that can be thrown from AthContainers.
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
SG::throwExcAllocOwnership
void throwExcAllocOwnership()
Throw a SG::ExcAllocOwnership exception.
Definition: Control/AthContainers/Root/exceptions.cxx:636
SG::ExcMissingViewVectorCLID
Exception — Missing CLID for ViewVector.
Definition: Control/AthContainers/AthContainers/exceptions.h:310
detail
Definition: extract_histogram_tag.cxx:14
SG::excConstAuxData_format
std::string excConstAuxData_format(const std::string &op, SG::auxid_t auxid)
Helper: format exception error string.
Definition: Control/AthContainers/Root/exceptions.cxx:115
SG::excFormatName
std::string excFormatName(SG::auxid_t auxid)
Helper: format an aux data item name.
Definition: Control/AthContainers/Root/exceptions.cxx:22
SG::ExcStoreLocked::ExcStoreLocked
ExcStoreLocked(SG::auxid_t auxid)
Constructor.
Definition: Control/AthContainers/Root/exceptions.cxx:276
SG::excAuxTypeMismatch_format
std::string excAuxTypeMismatch_format(SG::auxid_t auxid, const std::type_info &new_type, const std::type_info &old_type, const std::string &new_alloc_type, const std::string &old_alloc_type)
Helper: format exception error string.
Definition: Control/AthContainers/Root/exceptions.cxx:170
SG::excBadVarName_format
std::string excBadVarName_format(const std::string &name)
Helper: format exception error string.
Definition: Control/AthContainers/Root/exceptions.cxx:646
SG::ExcAllocOwnership::ExcAllocOwnership
ExcAllocOwnership()
Constructor.
Definition: Control/AthContainers/Root/exceptions.cxx:627
SG::ExcUnknownAuxItem
Exception — Unknown aux data item.
Definition: Control/AthContainers/AthContainers/exceptions.h:233
SG::ExcUnknownAuxItem::ExcUnknownAuxItem
ExcUnknownAuxItem(const std::string &name, const std::string &clsname="", const std::type_info *typ=0)
Constructor.
Definition: Control/AthContainers/Root/exceptions.cxx:339
SG::AuxTypeRegistry
Handle mappings between names and auxid_t.
Definition: AuxTypeRegistry.h:62
SG::throwExcMissingBaseInfo
void throwExcMissingBaseInfo(const std::type_info &ti)
Throw a SG::ExcMissingBaseInfo exception.
Definition: Control/AthContainers/Root/exceptions.cxx:447
AthContainers_detail
Definition: error.h:53
SG::Linked
@ Linked
Mark that this variable is linked to another one.
Definition: AuxTypes.h:77
SG::throwExcNonowningContainer
void throwExcNonowningContainer()
Throw a SG::ExcNonowningContainer exception.
Definition: Control/AthContainers/Root/exceptions.cxx:307
SG::auxid_t
size_t auxid_t
Identifier for a particular aux data item.
Definition: AuxTypes.h:27
SG::ExcInvalidThinningTarget::ExcInvalidThinningTarget
ExcInvalidThinningTarget(unsigned int clid, const std::string &key)
Constructor.
Definition: Control/AthContainers/Root/exceptions.cxx:602
SG::ExcViewVectorNotView::ExcViewVectorNotView
ExcViewVectorNotView()
Constructor.
Definition: Control/AthContainers/Root/exceptions.cxx:391
SG::excNoLinkedVar_format
std::string excNoLinkedVar_format(SG::auxid_t auxid, const std::type_info &type)
Helper: format exception error string.
Definition: Control/AthContainers/Root/exceptions.cxx:558
SG::ExcBadVarName::ExcBadVarName
ExcBadVarName(const std::string &name)
Constructor.
Definition: Control/AthContainers/Root/exceptions.cxx:662
SG::ExcAllocOwnership
Exception — Bad allocation ownership.
Definition: Control/AthContainers/AthContainers/exceptions.h:474
SG::excInvalidThinningTarget_format
std::string excInvalidThinningTarget_format(unsigned int clid, const std::string &key)
Helper: format exception error string.
Definition: Control/AthContainers/Root/exceptions.cxx:586
error.h
Helper for emitting error messages.
SG::ExcBadIterSwap::ExcBadIterSwap
ExcBadIterSwap()
Constructor.
Definition: Control/AthContainers/Root/exceptions.cxx:615
SG::ExcNonowningContainer
Exception — Attempted to insert a unique_ptr to a non-owning container.
Definition: Control/AthContainers/AthContainers/exceptions.h:208
SG::AuxVarFlags
AuxVarFlags
Additional flags to qualify an auxiliary variable.
Definition: AuxTypes.h:58
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
SG::ExcConstAuxData::ExcConstAuxData
ExcConstAuxData(const std::string &op, SG::auxid_t auxid=null_auxid)
Constructor.
Definition: Control/AthContainers/Root/exceptions.cxx:131
SG::excNoAuxStore_format
std::string excNoAuxStore_format(SG::auxid_t auxid)
Helper: format exception error string.
Definition: Control/AthContainers/Root/exceptions.cxx:44
SG::throwExcMissingViewVectorCLID
void throwExcMissingViewVectorCLID(const std::type_info &ti)
Throw a SG::ExcMissingViewVectorCLID exception.
Definition: Control/AthContainers/Root/exceptions.cxx:425
SG::ExcMissingBaseInfo::ExcMissingBaseInfo
ExcMissingBaseInfo(const std::type_info &ti)
Constructor.
Definition: Control/AthContainers/Root/exceptions.cxx:437
SG::ExcBadPrivateStore::ExcBadPrivateStore
ExcBadPrivateStore(const std::string &op)
Constructor.
Definition: Control/AthContainers/Root/exceptions.cxx:159
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
SG::ExcLinkMismatch::ExcLinkMismatch
ExcLinkMismatch(SG::auxid_t auxid, const std::type_info &type, SG::auxid_t existing_linked_id, SG::auxid_t requested_linked_id)
Constructor.
Definition: Control/AthContainers/Root/exceptions.cxx:544
SG::excDVToELV_format
std::string excDVToELV_format(const std::string &detail)
Helper: format exception error string.
Definition: Control/AthContainers/Root/exceptions.cxx:365
SG::throwExcUnknownAuxItem
void throwExcUnknownAuxItem(const std::string &name, const std::string &clsname="", const std::type_info *typ=0)
Throw a SG::ExcUnknownAuxItem exception.
Definition: Control/AthContainers/Root/exceptions.cxx:353
SG::ExcNoLinkedVar::ExcNoLinkedVar
ExcNoLinkedVar(SG::auxid_t auxid, const std::type_info &type)
Constructor.
Definition: Control/AthContainers/Root/exceptions.cxx:575
SG::ExcNonowningContainer::ExcNonowningContainer
ExcNonowningContainer()
Constructor.
Definition: Control/AthContainers/Root/exceptions.cxx:298
SG::ExcUntrackedSetStore::ExcUntrackedSetStore
ExcUntrackedSetStore()
Constructor.
Definition: Control/AthContainers/Root/exceptions.cxx:143
SG::Atomic
@ Atomic
Mark that this variable should only be accessed atomically.
Definition: AuxTypes.h:70
SG::excLinkMismatch_format
std::string excLinkMismatch_format(SG::auxid_t auxid, const std::type_info &type, SG::auxid_t existing_linked_id, SG::auxid_t requested_linked_id)
Helper: format exception error string.
Definition: Control/AthContainers/Root/exceptions.cxx:521
SG::excBadAuxVar_format
std::string excBadAuxVar_format(SG::auxid_t auxid)
Helper: format exception error string.
Definition: Control/AthContainers/Root/exceptions.cxx:90
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
SG::excUnknownAuxItem_format
std::string excUnknownAuxItem_format(const std::string &name, const std::string &clsname, const std::type_info *typ)
Helper: format exception error string.
Definition: Control/AthContainers/Root/exceptions.cxx:317
AuxTypeRegistry.h
Handle mappings between names and auxid_t.
SG::ExcDVToELV::ExcDVToELV
ExcDVToELV(const std::string &detail)
Constructor.
Definition: Control/AthContainers/Root/exceptions.cxx:379
SG::ExcInsertionInBaseClass::ExcInsertionInBaseClass
ExcInsertionInBaseClass(const char *op, const std::type_info &base_type, const std::type_info &complete_type)
Constructor.
Definition: Control/AthContainers/Root/exceptions.cxx:237
SG::ExcFlagMismatch::ExcFlagMismatch
ExcFlagMismatch(SG::auxid_t auxid, const std::type_info &type, SG::AuxVarFlags existing_flags, SG::AuxVarFlags requested_flags)
Constructor.
Definition: Control/AthContainers/Root/exceptions.cxx:508
SG::ExcMissingBaseInfo
Exception — Missing BaseInfo.
Definition: Control/AthContainers/AthContainers/exceptions.h:335
SG::ExcNoAuxStore::ExcNoAuxStore
ExcNoAuxStore(SG::auxid_t auxid)
Constructor.
Definition: Control/AthContainers/Root/exceptions.cxx:70
SG::excFormatFlags
std::string excFormatFlags(SG::AuxVarFlags flags)
Helper: format flags.
Definition: Control/AthContainers/Root/exceptions.cxx:469
SG::throwExcViewVectorNotView
void throwExcViewVectorNotView()
Throw a SG::ExcViewVectorNotView exception.
Definition: Control/AthContainers/Root/exceptions.cxx:400
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37