ATLAS Offline Software
Loading...
Searching...
No Matches
Control/AthContainers/Root/exceptions.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
10
11
15#include <sstream>
16
17
18namespace SG {
19
20
22std::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
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
56std::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
74
75
84
85
86//*************************************************************************
87
88
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
109
110
111//*************************************************************************
112
113
115std::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
131ExcConstAuxData::ExcConstAuxData (const std::string& op, SG::auxid_t auxid)
133{
134}
135
136
137//*************************************************************************
138
139
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)
205 new_type, old_type,
206 new_alloc_type,
207 old_alloc_type))
208{
209}
210
211
212//*************************************************************************
213
214
216std::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)
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
262std::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
280
281
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
311
312
313//*************************************************************************
314
315
317std::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
353void 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
365std::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
379ExcDVToELV::ExcDVToELV (const std::string& detail)
381{
382}
383
384
385//*************************************************************************
386
387
392 : std::runtime_error ("ViewVector not in view mode.")
393{
394}
395
396
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
425void throwExcMissingViewVectorCLID (const std::type_info& ti)
426{
427 throw ExcMissingViewVectorCLID (ti);
428}
429
430
431//*************************************************************************
432
433
438 : std::runtime_error ("Missing BaseInfo for " +
439 AthContainers_detail::typeinfoName(ti))
440{
441}
442
443
447void 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;
472 if (flags & SG::AuxVarFlags::Atomic)
473 out = "atomic";
474 if (flags & SG::AuxVarFlags::Linked) {
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)
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)
578{
579}
580
581
582//*************************************************************************
583
584
586std::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)
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
646std::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
662ExcBadVarName::ExcBadVarName (const std::string& name)
664{
665}
666
667
668//*************************************************************************
669
670
673{
674 return "SG::ExcJaggedVecOverlappingCopy: Overlapping copies not implemented for jagged vectors. Talk to core software if this is an issue.";
675}
676
677
685
686
694
695
696} // 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.
STL class.
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
@ Linked
Mark that this variable is linked to another one.
Definition AuxTypes.h:77
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.
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.