ATLAS Offline Software
Loading...
Searching...
No Matches
Calorimeter/CaloCondBlobObjs/CaloCondBlobObjs/Exception.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef CALOCONDBLOBOBJS_EXCEPTION_H
6#define CALOCONDBLOBOBJS_EXCEPTION_H
7
8#include <exception>
9#include <string>
10#include <sstream>
11
12namespace CaloCond {
13
14 //
15 //__________________________________________________________________________________
20 class Exception : public std::exception {
21 public:
22 explicit Exception( const std::string& domain, const std::string& message)
23 : m_domain(domain), m_message(domain + ": " + message){}
24 virtual ~Exception() throw() {}
25
26 virtual const char* what() const throw(){
27 return m_message.c_str();
28 }
29
30 virtual const std::string& domain() const{
31 return m_domain;
32 }
33
34 protected:
35 virtual void setMessage( const std::string& message ){
36 m_message = m_domain + ": " + message;
37 }
38
39 private:
40 std::string m_domain;
41 std::string m_message;
42 };
43
44
45 //
46 //__________________________________________________________________________________
50 class InvalidBlob: public Exception {
51 public:
52 explicit InvalidBlob( const std::string& domain )
53 : Exception( domain, "Invalid Blob" )
54 {
55 }
56 virtual ~InvalidBlob() throw() {}
57 };
58
59 //
60 //__________________________________________________________________________________
64 class VersionConflict: public Exception {
65 public:
66 explicit VersionConflict( const std::string& domain,
67 unsigned int version_is,
68 unsigned int version_should=0)
69 : Exception( domain, "" )
70 {
71 std::ostringstream msg;
72 msg << "Blob Version conflict. Is " << version_is;
73 if(version_should){ msg << " but should be " << version_should; }
74 setMessage(msg.str());
75 }
76 virtual ~VersionConflict() throw() {}
77 };
78
79 //
80 //__________________________________________________________________________________
84 class TypeConflict: public Exception {
85 public:
86 explicit TypeConflict( const std::string& domain,
87 unsigned int version_is,
88 unsigned int version_should=0)
89 : Exception( domain, "" )
90 {
91 std::ostringstream msg;
92 msg << "Blob Type conflict. Is " << version_is;
93 if(version_should){ msg << " but should be " << version_should; }
94 setMessage(msg.str());
95 }
96 virtual ~TypeConflict() throw() {}
97 };
98
99 //
100 //__________________________________________________________________________________
104 class SizeConflict: public Exception {
105 public:
106 explicit SizeConflict( const std::string& domain,
107 unsigned int size_is,
108 unsigned int size_should)
109 : Exception( domain, "" )
110 {
111 std::ostringstream msg;
112 msg << "Blob Size conflict. Is " << size_is
113 << " but should be " << size_should;
114 setMessage(msg.str());
115 }
116 virtual ~SizeConflict() throw() {}
117 };
118
119 //
120 //__________________________________________________________________________________
124 class IndexOutOfRange : public Exception {
125 public:
126 explicit IndexOutOfRange( const std::string& domain,
127 unsigned int idx,
128 unsigned int maxRange=0)
129 : Exception( domain, "" )
130 {
131 std::ostringstream msg;
132 msg << "Index out of range: " << idx;
133 if(maxRange>0){
134 msg << " >= " << maxRange;
135 }
136 setMessage(msg.str());
137 }
138 virtual ~IndexOutOfRange() throw() {}
139 };
140
141 //
142 //__________________________________________________________________________________
146 class InvalidCaloGain : public Exception {
147 public:
148 explicit InvalidCaloGain( const std::string& domain,
149 int caloGain)
150 : Exception( domain, "" )
151 {
152 std::ostringstream msg;
153 msg << "Invalid CaloGain: " << caloGain;
154 setMessage(msg.str());
155 }
156 virtual ~InvalidCaloGain() throw() {}
157 };
158
159}
160#endif
Exception(const std::string &domain, const std::string &message)
virtual void setMessage(const std::string &message)
IndexOutOfRange(const std::string &domain, unsigned int idx, unsigned int maxRange=0)
SizeConflict(const std::string &domain, unsigned int size_is, unsigned int size_should)
TypeConflict(const std::string &domain, unsigned int version_is, unsigned int version_should=0)
VersionConflict(const std::string &domain, unsigned int version_is, unsigned int version_should=0)
MsgStream & msg
Definition testRead.cxx:32