ATLAS Offline Software
Control/SGTools/src/exceptions.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
12 #include "SGTools/exceptions.h"
13 #include "GaudiKernel/System.h"
14 #include <sstream>
15 #include <string>
16 
17 
18 namespace SG {
19 
20 
22 std::string excBadDataProxyCast_format (CLID id, const std::type_info& tid)
23 {
24  std::ostringstream os;
25  os << "Bad cast of DataProxy with CLID " << id
26  << " to type " << System::typeinfoName (tid);
27  return os.str();
28 }
29 
30 
36 ExcBadDataProxyCast::ExcBadDataProxyCast (CLID id, const std::type_info& tid)
37  : m_what (excBadDataProxyCast_format (id, tid))
38 {
39 }
40 
41 
45 const char* ExcBadDataProxyCast::what() const throw()
46 {
47  return m_what.c_str();
48 }
49 
50 
56 void throwExcBadDataProxyCast (CLID id, const std::type_info& tid)
57 {
58  throw ExcBadDataProxyCast (id, tid);
59 }
60 
61 
62 //*************************************************************************
63 
64 
67  const std::string& key,
68  CLID primary_id,
69  const std::string& primary_key)
70 {
71  std::ostringstream os;
72  os << "ExcProxyCollision: proxy collision for clid/key "
73  << id << " / " << key
74  << " (primary " << primary_id << " / " << primary_key << ").";
75  return os.str();
76 }
77 
78 
87  const std::string& key,
88  CLID primary_id,
89  const std::string& primary_key)
90  : std::runtime_error (excProxyCollision_format (id,
91  key,
92  primary_id,
93  primary_key))
94 {
95 }
96 
97 
98 //*************************************************************************
99 
100 
102 std::string excSgkeyCollision_format (const std::string& new_key,
103  CLID new_clid,
104  const std::string& old_key,
105  CLID old_clid,
106  sgkey_t sgkey)
107 {
108  std::ostringstream os;
109  os << "ExcSgkeyCollision: sgkey hash collision; new key: "
110  << new_key << "/" << new_clid << " and existing key: "
111  << old_key << "/" << old_clid << " both hash to " << sgkey;
112  return os.str();
113 }
114 
115 
124 ExcSgkeyCollision::ExcSgkeyCollision (const std::string& new_key,
125  CLID new_clid,
126  const std::string& old_key,
127  CLID old_clid,
128  sgkey_t sgkey)
129  : std::runtime_error (excSgkeyCollision_format (new_key, new_clid,
130  old_key, old_clid,
131  sgkey))
132 {
133 }
134 
135 
136 } // namespace SG
SG::ExcBadDataProxyCast::what
virtual const char * what() const
Return the message for this exception.
Definition: Control/SGTools/src/exceptions.cxx:45
common.sgkey
def sgkey(tool)
Definition: common.py:1028
exceptions.h
Exceptions that can be thrown by SGTools.
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:36
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:124
SG::ExcBadDataProxyCast
Exception — Bad cast of DataProxy with CLID.
Definition: Control/SGTools/SGTools/exceptions.h:35
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:66
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:102
SG::ExcBadDataProxyCast::m_what
std::string m_what
The message for this exception.
Definition: Control/SGTools/SGTools/exceptions.h:57
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:220
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:86
SG::excBadDataProxyCast_format
std::string excBadDataProxyCast_format(CLID id, const std::type_info &tid)
Helper: Format exception string.
Definition: Control/SGTools/src/exceptions.cxx:22
SG::throwExcBadDataProxyCast
void throwExcBadDataProxyCast(CLID id, const std::type_info &tid)
Throw an ExcBadDataProxyCast exception.
Definition: Control/SGTools/src/exceptions.cxx:56
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37