ATLAS Offline Software
Loading...
Searching...
No Matches
Control/SGTools/src/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
12#include "SGTools/exceptions.h"
13#include "SGTools/DataProxy.h"
14#include "GaudiKernel/System.h"
15#include <format>
16#include <string>
17
18
19namespace SG {
20
21
23std::string excBadDataProxyCast_format (CLID id, const std::type_info& tid)
24{
25 return std::format ("ExcBadDataProxyCast: Bad cast of DataProxy with CLID {} to type {}",
26 id, System::typeinfoName (tid));
27}
28
29
35ExcBadDataProxyCast::ExcBadDataProxyCast (CLID id, const std::type_info& tid)
37{
38}
39
40
44const char* ExcBadDataProxyCast::what() const noexcept
45{
46 return m_what.c_str();
47}
48
49
55void throwExcBadDataProxyCast (const DataProxy& proxy, const std::type_info& tid)
56{
57 throw ExcBadDataProxyCast (proxy.clID(), tid);
58}
59
60
61//*************************************************************************
62
63
66 const std::string& key,
67 CLID primary_id,
68 const std::string& primary_key)
69{
70 return std::format ("ExcProxyCollision: proxy collision for clid/key {} / {}"
71 " (primary {} / {}).",
72 id, key, primary_id, primary_key);
73}
74
75
84 const std::string& key,
85 CLID primary_id,
86 const std::string& primary_key)
87 : std::runtime_error (excProxyCollision_format (id,
88 key,
89 primary_id,
90 primary_key))
91{
92}
93
94
95//*************************************************************************
96
97
99std::string excSgkeyCollision_format (const std::string& new_key,
100 CLID new_clid,
101 const std::string& old_key,
102 CLID old_clid,
103 sgkey_t sgkey)
104{
105 return std::format ("ExcSgkeyCollision: sgkey hash collision; "
106 "new key: {}/{} and existing key: {}/{} both hash to {}",
107 new_key, new_clid, old_key, old_clid, sgkey);
108}
109
110
119ExcSgkeyCollision::ExcSgkeyCollision (const std::string& new_key,
120 CLID new_clid,
121 const std::string& old_key,
122 CLID old_clid,
123 sgkey_t sgkey)
124 : std::runtime_error (excSgkeyCollision_format (new_key, new_clid,
125 old_key, old_clid,
126 sgkey))
127{
128}
129
130
131} // namespace SG
Exceptions that can be thrown by SGTools.
uint32_t CLID
The Class ID type.
Exception — Bad cast of DataProxy with CLID.
virtual const char * what() const noexcept override
Return the message for this exception.
std::string m_what
The message for this exception.
ExcBadDataProxyCast(CLID id, const std::type_info &tid)
Constructor.
ExcProxyCollision(CLID id, const std::string &key, CLID primary_id, const std::string &primary_key)
Constructor.
ExcSgkeyCollision(const std::string &new_key, CLID new_clid, const std::string &old_key, CLID old_clid, sgkey_t sgkey)
Constructor.
Forward declaration.
void throwExcBadDataProxyCast(const DataProxy &proxy, const std::type_info &tid)
Throw an ExcBadDataProxyCast exception.
std::string excBadDataProxyCast_format(CLID id, const std::type_info &tid)
Helper: Format exception string.
uint32_t sgkey_t
Type used for hashed StoreGate key+CLID pairs.
Definition sgkey_t.h:32
std::string excSgkeyCollision_format(const std::string &new_key, CLID new_clid, const std::string &old_key, CLID old_clid, sgkey_t sgkey)
Helper: Format exception string.
std::string excProxyCollision_format(CLID id, const std::string &key, CLID primary_id, const std::string &primary_key)
Helper: Format exception string.
STL namespace.