Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 */
12 #include "SGTools/exceptions.h"
13 #include "SGTools/DataProxy.h"
14 #include "GaudiKernel/System.h"
15 #include <sstream>
16 #include <string>
17 
18 
19 namespace SG {
20 
21 
23 std::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 
37 ExcBadDataProxyCast::ExcBadDataProxyCast (CLID id, const std::type_info& tid)
38  : m_what (excBadDataProxyCast_format (id, tid))
39 {
40 }
41 
42 
46 const char* ExcBadDataProxyCast::what() const throw()
47 {
48  return m_what.c_str();
49 }
50 
51 
57 void 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)
91  : std::runtime_error (excProxyCollision_format (id,
92  key,
93  primary_id,
94  primary_key))
95 {
96 }
97 
98 
99 //*************************************************************************
100 
101 
103 std::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 
125 ExcSgkeyCollision::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
SG::ExcBadDataProxyCast::what
virtual const char * what() const
Return the message for this exception.
Definition: Control/SGTools/src/exceptions.cxx:46
common.sgkey
def sgkey(tool)
Definition: common.py:1028
exceptions.h
Exceptions that can be thrown by SGTools.
StateLessPT_NewConfig.proxy
proxy
Definition: StateLessPT_NewConfig.py:392
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
SG::ExcBadDataProxyCast::ExcBadDataProxyCast
ExcBadDataProxyCast(CLID id, const std::type_info &tid)
Constructor.
Definition: Control/SGTools/src/exceptions.cxx:37
SG::ExcSgkeyCollision::ExcSgkeyCollision
ExcSgkeyCollision(const std::string &new_key, CLID new_clid, const std::string &old_key, CLID old_clid, sgkey_t sgkey)
Constructor.
Definition: Control/SGTools/src/exceptions.cxx:125
SG::throwExcBadDataProxyCast
void throwExcBadDataProxyCast(const DataProxy &proxy, const std::type_info &tid)
Throw an ExcBadDataProxyCast exception.
Definition: Control/SGTools/src/exceptions.cxx:57
SG::ExcBadDataProxyCast
Exception — Bad cast of DataProxy with CLID.
Definition: Control/SGTools/SGTools/exceptions.h:38
Athena::typeinfoName
std::string typeinfoName(const std::type_info &ti)
Convert a type_info to a demangled string.
Definition: AthenaKernel/src/ClassName.cxx:23
SG::excProxyCollision_format
std::string excProxyCollision_format(CLID id, const std::string &key, CLID primary_id, const std::string &primary_key)
Helper: Format exception string.
Definition: Control/SGTools/src/exceptions.cxx:67
SG::excSgkeyCollision_format
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.
Definition: Control/SGTools/src/exceptions.cxx:103
SG::ExcBadDataProxyCast::m_what
std::string m_what
The message for this exception.
Definition: Control/SGTools/SGTools/exceptions.h:60
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:239
SG::sgkey_t
uint32_t sgkey_t
Type used for hashed StoreGate key+CLID pairs.
Definition: CxxUtils/CxxUtils/sgkey_t.h:32
SG::ExcProxyCollision::ExcProxyCollision
ExcProxyCollision(CLID id, const std::string &key, CLID primary_id, const std::string &primary_key)
Constructor.
Definition: Control/SGTools/src/exceptions.cxx:87
SG::excBadDataProxyCast_format
std::string excBadDataProxyCast_format(CLID id, const std::type_info &tid)
Helper: Format exception string.
Definition: Control/SGTools/src/exceptions.cxx:23
SG::DataProxy
Definition: DataProxy.h:45
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
DataProxy.h