ATLAS Offline Software
Loading...
Searching...
No Matches
Control/SGTools/src/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
12#include "SGTools/exceptions.h"
13#include "SGTools/DataProxy.h"
14#include "GaudiKernel/System.h"
15#include <sstream>
16#include <string>
17
18
19namespace SG {
20
21
23std::string excBadDataProxyCast_format (CLID id, const std::type_info& tid)
24{
25 std::ostringstream os;
26 os << "Bad cast of DataProxy with CLID " << id
27 << " to type " << System::typeinfoName (tid);
28 return os.str();
29}
30
31
37ExcBadDataProxyCast::ExcBadDataProxyCast (CLID id, const std::type_info& tid)
39{
40}
41
42
46const char* ExcBadDataProxyCast::what() const noexcept
47{
48 return m_what.c_str();
49}
50
51
57void throwExcBadDataProxyCast (const DataProxy& proxy, const std::type_info& tid)
58{
59 throw ExcBadDataProxyCast (proxy.clID(), tid);
60}
61
62
63//*************************************************************************
64
65
68 const std::string& key,
69 CLID primary_id,
70 const std::string& primary_key)
71{
72 std::ostringstream os;
73 os << "ExcProxyCollision: proxy collision for clid/key "
74 << id << " / " << key
75 << " (primary " << primary_id << " / " << primary_key << ").";
76 return os.str();
77}
78
79
88 const std::string& key,
89 CLID primary_id,
90 const std::string& primary_key)
92 key,
93 primary_id,
94 primary_key))
95{
96}
97
98
99//*************************************************************************
100
101
103std::string excSgkeyCollision_format (const std::string& new_key,
104 CLID new_clid,
105 const std::string& old_key,
106 CLID old_clid,
107 sgkey_t sgkey)
108{
109 std::ostringstream os;
110 os << "ExcSgkeyCollision: sgkey hash collision; new key: "
111 << new_key << "/" << new_clid << " and existing key: "
112 << old_key << "/" << old_clid << " both hash to " << sgkey;
113 return os.str();
114}
115
116
125ExcSgkeyCollision::ExcSgkeyCollision (const std::string& new_key,
126 CLID new_clid,
127 const std::string& old_key,
128 CLID old_clid,
129 sgkey_t sgkey)
130 : std::runtime_error (excSgkeyCollision_format (new_key, new_clid,
131 old_key, old_clid,
132 sgkey))
133{
134}
135
136
137} // 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.
STL class.
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.