ATLAS Offline Software
Loading...
Searching...
No Matches
Control/AthContainers/Root/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
15#include <format>
16
17
18namespace SG {
19
20
23{
24 if (auxid != null_auxid) {
26 return std::format ("`{}::{}' ({})",
27 r.getClassName (auxid),
28 r.getName (auxid),
29 auxid);
30 }
31 return "(null)";
32}
33
34
35//*************************************************************************
36
37
40{
41 return std::format ("SG::ExcNoAuxStore: "
42 "Requested aux data item {} but there is no associated aux data store.",
44}
45
46
48std::string excNoAuxStore_format (const char* op)
49{
50 return std::format ("SG::ExcNoAuxStore: "
51 "Operation attempted on container with no associated aux data store: {}", op);;
52}
53
54
63
64
70 : std::runtime_error (excNoAuxStore_format (op))
71{
72}
73
74
75//*************************************************************************
76
77
80{
81 return std::format ("SG::ExcBadAuxVar: "
82 "Attempt to retrieve nonexistent aux data item {}.",
84}
85
86
95
96
97//*************************************************************************
98
99
101std::string excConstAuxData_format (const std::string& op, SG::auxid_t auxid)
102{
103 return std::format ("SG::ExcConstAuxData: "
104 "Non-const operation `{}' performed on const aux data {}.",
105 op, excFormatName (auxid));
106}
107
108
115 : std::runtime_error (excConstAuxData_format (op, auxid))
116{
117}
118
119
120//*************************************************************************
121
122
127 : std::runtime_error
128 ("SG::ExcUntrackedSetStore: "
129 "Attempt to set aux data store on container that doesn't track indices, "
130 "or disable index tracking for a container with aux data.")
131{
132}
133
134
135//*************************************************************************
136
137
143 : std::runtime_error ("SG::ExcBadPrivateStore: "
144 "Bad use of private store: " + op)
145{
146}
147
148
149//*************************************************************************
150
151
154 const std::type_info& new_type,
155 const std::type_info& old_type,
156 const std::string& new_alloc_type,
157 const std::string& old_alloc_type)
158{
159 std::string s =
160 std::format ("SG::ExcAuxTypeMismatch: "
161 "Type mismatch for aux variable {}; old type is {} new type is {}",
163 AthContainers_detail::typeinfoName (old_type),
164 AthContainers_detail::typeinfoName (new_type));
165 if (old_alloc_type != new_alloc_type)
166 {
167 s += std::format (". Old allocator type is {} new allocator type is {}",
168 old_alloc_type, new_alloc_type);
169 }
170 return s;
171}
172
173
183 const std::type_info& new_type,
184 const std::type_info& old_type,
185 const std::string& new_alloc_type,
186 const std::string& old_alloc_type)
187 : std::runtime_error (excAuxTypeMismatch_format (auxid,
188 new_type, old_type,
189 new_alloc_type,
190 old_alloc_type))
191{
192}
193
194
195//*************************************************************************
196
197
199std::string excInsertionInBaseClass_format (const char* op,
200 const std::type_info& base_type,
201 const std::type_info& complete_type)
202{
203 return std::format ("SG::ExcInsertionInBaseClass: "
204 "Attempted to do {} on a {} base class of {}; can only be done on the most-derived class.",
205 op,
206 AthContainers_detail::typeinfoName (base_type),
207 AthContainers_detail::typeinfoName (complete_type));
208}
209
210
218 (const char* op,
219 const std::type_info& base_type,
220 const std::type_info& complete_type)
221 : std::runtime_error (excInsertionInBaseClass_format (op,
222 base_type,
223 complete_type))
224{
225}
226
227
228//*************************************************************************
229
230
233{
234 return std::format ("SG::ExcStoreLocked: "
235 "Attempted to modify auxiliary data in a locked store: {}",
237}
238
239
241std::string excStoreLocked_format (const char* op)
242{
243 return std::format ("SG::ExcStoreLocked: "
244 "Attempted to modify auxiliary data in a locked store: {}", op);
245}
246
247
256
257
263 : std::runtime_error (excStoreLocked_format (op))
264{
265}
266
267
268//*************************************************************************
269
270
275 : std::runtime_error ("SG::ExcNonowningContainer: Attempted to insert a unique_ptr to a non-owning container.")
276{
277}
278
279
287
288
289//*************************************************************************
290
291
293std::string excUnknownAuxItem_format (const std::string& name,
294 const std::string& clsname,
295 const std::type_info* typ)
296{
297 std::string s = std::format ("SG::ExcUnknownAuxItem: "
298 "Unknown aux data item {}{}{}",
299 clsname, (clsname.empty() ? "" : "::"), name);
300 if (typ)
301 s += std::format (" (of type {})",
302 AthContainers_detail::typeinfoName (*typ));
303 return s;
304}
305
306
314 const std::string& clsname /*= ""*/,
315 const std::type_info* typ /*= 0*/)
316 : std::runtime_error (excUnknownAuxItem_format (name, clsname, typ))
317{
318}
319
320
327void throwExcUnknownAuxItem (const std::string& name,
328 const std::string& clsname /*= ""*/,
329 const std::type_info* typ /*= 0*/)
330{
331 throw ExcUnknownAuxItem (name, clsname, typ);
332}
333
334
335//*************************************************************************
336
337
339std::string excDVToELV_format (const std::string& detail)
340{
341 return std::format ("SG::ExcDVToELV: "
342 "Can't convert DataVector to vector of ElementLinks: {}",
343 detail);
344}
345
346
351ExcDVToELV::ExcDVToELV (const std::string& detail)
352 : std::runtime_error (excDVToELV_format (detail))
353{
354}
355
356
357//*************************************************************************
358
359
364 : std::runtime_error ("ViewVector not in view mode.")
365{
366}
367
368
376
377
378//*************************************************************************
379
380
385 : std::runtime_error ("ViewVector " + AthContainers_detail::typeinfoName(ti) +
386 "was used in a context that requires a CLID, "
387 "but no CLID was available. Make sure a "
388 "VIEWVECTOR_CLASS_DEF declaration exists for the class "
389 "in a library that has been loaded.")
390{
391}
392
393
397void throwExcMissingViewVectorCLID (const std::type_info& ti)
398{
399 throw ExcMissingViewVectorCLID (ti);
400}
401
402
403//*************************************************************************
404
405
410 : std::runtime_error ("Missing BaseInfo for " +
411 AthContainers_detail::typeinfoName(ti))
412{
413}
414
415
419void throwExcMissingBaseInfo (const std::type_info& ti)
420{
421 throw ExcMissingBaseInfo (ti);
422}
423
424
425//*************************************************************************
426
427
432 : std::runtime_error ("Ownership mismatch for insertMove.")
433{
434}
435
436
437//*************************************************************************
438
439
442{
443 std::string out;
444 if (flags & SG::AuxVarFlags::Atomic)
445 out = "atomic";
446 if (flags & SG::AuxVarFlags::Linked) {
447 if (!out.empty()) out += " ";
448 out = "linked";
449 }
450
451 return "[" + out + "]";
452}
453
454
457 const std::type_info& type,
458 SG::AuxVarFlags existing_flags,
459 SG::AuxVarFlags requested_flags)
460{
461 return std::format ("SG::ExcFlagMismatch: "
462 "Flag mismatch for aux variable {} of type {} between existing {} and requested {} flags. "
463 "This may occur as a result of not using AtomicDecorator to access an atomic variable.",
465 AthContainers_detail::typeinfoName (type),
466 excFormatFlags (existing_flags),
467 excFormatFlags (requested_flags));
468}
469
470
479 const std::type_info& type,
480 SG::AuxVarFlags existing_flags,
481 SG::AuxVarFlags requested_flags)
482 : std::runtime_error (excFlagMismatch_format (auxid, type, existing_flags, requested_flags))
483{
484}
485
486
487//*************************************************************************
488
489
492 const std::type_info& type,
493 SG::auxid_t existing_linked_id,
494 SG::auxid_t requested_linked_id)
495{
496 return std::format ("SG::ExcLinkMismatch: "
497 "Linked variable mismatch for aux variable {} of type {} between existing {} and requested {} linked variables.",
499 AthContainers_detail::typeinfoName (type),
500 excFormatName (existing_linked_id),
501 excFormatName (requested_linked_id));
502}
503
504
513 const std::type_info& type,
514 SG::auxid_t existing_linked_id,
515 SG::auxid_t requested_linked_id)
516 : std::runtime_error (excLinkMismatch_format (auxid, type,
517 existing_linked_id, requested_linked_id))
518{
519}
520
521
522//*************************************************************************
523
524
527 const std::type_info& type)
528{
529 return std::format ("SG::ExcNoLinkedVar: "
530 "Linked variable not found for aux variable {} of type {}",
531 excFormatName (auxid), AthContainers_detail::typeinfoName (type));
532}
533
534
541 const std::type_info& type)
542 : std::runtime_error (excNoLinkedVar_format (auxid, type))
543{
544}
545
546
547//*************************************************************************
548
549
551std::string excInvalidThinningTarget_format (unsigned int clid,
552 const std::string& key)
553{
554 return std::format ("SG::ExcInvalidThinningTarget: "
555 "ThinningHandle target does not exist: {}/{}",
556 clid, key);
557}
558
559
566 const std::string& key)
567 : std::runtime_error (excInvalidThinningTarget_format (clid, key))
568{
569}
570
571
572//*************************************************************************
573
574
579 : std::runtime_error ("SG::ExcBadIterSwap: Attempt to swap between containers with inconsistent ownership.")
580{
581}
582
583
584//*************************************************************************
585
586
591 : std::runtime_error ("SG::ExcAllocOwnership: Bad allocation ownership.")
592{
593}
594
595
600{
601 throw ExcAllocOwnership();
602}
603
604
605//*************************************************************************
606
607
609std::string excBadVarName_format (const std::string& name)
610{
611 return std::format ("SG::ExcBadVarName: "
612 "Bad name for auxiliary variable `{}'. "
613 "Variable and class names must consist of only digits, letters, "
614 "and underscores, and cannot start with a digit. "
615 "Variable names may not be empty, but class names may be.",
616 name);
617}
618
619
624ExcBadVarName::ExcBadVarName (const std::string& name)
625 : std::runtime_error (excBadVarName_format (name))
626{
627}
628
629
630//*************************************************************************
631
632
635{
636 return "SG::ExcJaggedVecOverlappingCopy: Overlapping copies not implemented for jagged vectors. Talk to core software if this is an issue.";
637}
638
639
647
648
656
657
658} // namespace SG
Handle mappings between names and auxid_t.
Exceptions that can be thrown from AthContainers.
Handle mappings between names and auxid_t.
static AuxTypeRegistry & instance()
Return the singleton registry instance.
Exception — Bad allocation ownership.
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.
ExcBadAuxVar(SG::auxid_t auxid)
Constructor.
ExcBadPrivateStore(const std::string &op)
Constructor.
ExcBadVarName(const std::string &name)
Constructor.
ExcConstAuxData(const std::string &op, SG::auxid_t auxid=null_auxid)
Constructor.
ExcDVToELV(const std::string &detail)
Constructor.
ExcFlagMismatch(SG::auxid_t auxid, const std::type_info &type, SG::AuxVarFlags existing_flags, SG::AuxVarFlags requested_flags)
Constructor.
ExcInsertionInBaseClass(const char *op, const std::type_info &base_type, const std::type_info &complete_type)
Constructor.
ExcInvalidThinningTarget(unsigned int clid, const std::string &key)
Constructor.
Exception — Overlapping copies not implemented for jagged vectors.
ExcLinkMismatch(SG::auxid_t auxid, const std::type_info &type, SG::auxid_t existing_linked_id, SG::auxid_t requested_linked_id)
Constructor.
ExcMissingBaseInfo(const std::type_info &ti)
Constructor.
ExcMissingViewVectorCLID(const std::type_info &ti)
Constructor.
ExcNoAuxStore(SG::auxid_t auxid)
Constructor.
ExcNoLinkedVar(SG::auxid_t auxid, const std::type_info &type)
Constructor.
Exception — Attempted to insert a unique_ptr to a non-owning container.
ExcStoreLocked(SG::auxid_t auxid)
Constructor.
ExcUnknownAuxItem(const std::string &name, const std::string &clsname="", const std::type_info *typ=0)
Constructor.
Exception — ViewVector not in view mode.
Helper for emitting error messages.
int r
Definition globals.cxx:22
Forward declaration.
std::string excInvalidThinningTarget_format(unsigned int clid, const std::string &key)
Helper: format exception error string.
AuxVarFlags
Additional flags to qualify an auxiliary variable.
Definition AuxTypes.h:58
@ Atomic
Mark that this variable should only be accessed atomically.
Definition AuxTypes.h:70
std::string excDVToELV_format(const std::string &detail)
Helper: format exception error string.
void throwExcViewVectorNotView()
Throw a SG::ExcViewVectorNotView exception.
std::string excFormatFlags(SG::AuxVarFlags flags)
Helper: format flags.
static const auxid_t null_auxid
To signal no aux data item.
Definition AuxTypes.h:30
void throwExcAllocOwnership()
Throw a SG::ExcAllocOwnership exception.
std::string excBadVarName_format(const std::string &name)
Helper: format exception error string.
SG::auxid_t auxid() const
Return the aux id for this variable.
std::string excBadAuxVar_format(SG::auxid_t auxid)
Helper: format exception error string.
std::string excNoLinkedVar_format(SG::auxid_t auxid, const std::type_info &type)
Helper: format exception error string.
void throwJaggedVecOverlappingCopy()
Throw a SG::ExcJaggedVecOverlappingCopy exception.
std::string excJaggedVecOverlappingCopy_format()
Helper: format exception error string.
void throwExcMissingBaseInfo(const std::type_info &ti)
Throw a SG::ExcMissingBaseInfo exception.
std::string excStoreLocked_format(SG::auxid_t auxid)
Helper: format exception error string.
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.
std::string excNoAuxStore_format(SG::auxid_t auxid)
Helper: format exception error string.
void throwExcNonowningContainer()
Throw a SG::ExcNonowningContainer exception.
std::string excConstAuxData_format(const std::string &op, SG::auxid_t auxid)
Helper: format exception error string.
std::string excFormatName(SG::auxid_t auxid)
Helper: format an aux data item name.
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.
void throwExcUnknownAuxItem(const std::string &name, const std::string &clsname="", const std::type_info *typ=0)
Throw a SG::ExcUnknownAuxItem exception.
std::string excInsertionInBaseClass_format(const char *op, const std::type_info &base_type, const std::type_info &complete_type)
Helper: format exception error string.
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.
std::string excUnknownAuxItem_format(const std::string &name, const std::string &clsname, const std::type_info *typ)
Helper: format exception error string.
void throwExcMissingViewVectorCLID(const std::type_info &ti)
Throw a SG::ExcMissingViewVectorCLID exception.
size_t auxid_t
Identifier for a particular aux data item.
Definition AuxTypes.h:27
STL namespace.