CFEL - ASG Software Suite  2.5.0
CASS
cass_exceptions.hpp
Go to the documentation of this file.
1 // Copyright (C) 2010 Lutz Foucar
2 
3 /**
4  * @file cass_exceptions.hpp file contains custom exceptions used in cass
5  *
6  * @author Lutz Foucar
7  */
8 
9 #ifndef __CASS_EXCEPTIONS_HPP__
10 #define __CASS_EXCEPTIONS_HPP__
11 
12 #include <stdexcept>
13 
14 namespace cass
15 {
16 /** Exception thrown when accessing invalid histogram
17  *
18  * adapted by Lutz Foucar 2017
19  *
20  * @author Jochen Küpper
21  */
22 class InvalidResultError : public std::out_of_range
23 {
24 public:
25  explicit InvalidResultError(const std::string &name, uint64_t id)
26  : std::out_of_range("")
27  {
28  std::ostringstream msg;
29  msg << "result of processor '"<< name << "' for event id '" << id
30  << "' is not available";
31  static_cast<std::out_of_range&>(*this) = std::out_of_range(msg.str());
32  }
33 
34  virtual ~InvalidResultError() throw(){}
35 };
36 
37 
38 /** Exception thrown when accessing invalid processor
39  *
40  * @author Lutz Foucar
41  */
42 class InvalidProcessorError : public std::out_of_range
43 {
44 public:
45  explicit InvalidProcessorError(const std::string &key)
46  : std::out_of_range("Invalid processor '" + key + "' requested!")
47  {}
48 
49  virtual ~InvalidProcessorError() throw(){}
50 };
51 
52 /** Exception thrown when there is a problem with deserializing QDataStreams
53  *
54  * @author Lutz Foucar
55  */
56 class DeserializeError : public std::runtime_error
57 {
58 public:
59  /** explicit constructor
60  *
61  * @param message the error message
62  */
63  explicit DeserializeError(const std::string & message)
64  : std::runtime_error(message)
65  {
66 
67  }
68 
69  virtual ~DeserializeError() throw() {}
70 };
71 
72 /** Exception thrown when one needs to reastart the input loop
73  *
74  * @author Lutz Foucar
75  */
76 class RestartInputLoop : public std::runtime_error
77 {
78 public:
79  /** explicit constructor
80  *
81  * @param message the error message
82  */
83  explicit RestartInputLoop(const std::string & message ="")
84  : std::runtime_error(message)
85  {
86 
87  }
88 
89  virtual ~RestartInputLoop() throw() {}
90 };
91 
92 
93 /** Exception thrown when there is a problem during data generation
94  *
95  * @author Lutz Foucar
96  */
97 class DataGenerationError : public std::runtime_error
98 {
99 public:
100  /** explicit constructor
101  *
102  * @param message the error message
103  */
104  explicit DataGenerationError(const std::string & message)
105  : std::runtime_error(message)
106  {}
107 
108  virtual ~DataGenerationError() throw() {}
109 };
110 
111 
112 /** Exception thrown when there is a problem with the data
113  *
114  * @author Lutz Foucar
115  */
116 class InvalidData : public std::logic_error
117 {
118 public:
119  /** explicit constructor
120  *
121  * @param message the error message
122  */
123  explicit InvalidData(const std::string & message)
124  : std::logic_error(message)
125  {}
126 
127  virtual ~InvalidData() throw() {}
128 };
129 
130 /** Exception thrown when a timeout occured
131  *
132  * When wating too long for a new processable element this should
133  * be thrown
134  */
135 class ProcessableTimedout : public std::runtime_error
136 {
137 public:
138  /** explicit constructor
139  *
140  * @param message the error message
141  */
142  explicit ProcessableTimedout(const std::string & message)
143  : std::runtime_error(message)
144  {}
145 
146  virtual ~ProcessableTimedout() throw() {}
147 
148 };
149 
150 /** Exception thrown when SACLA tag is outdated
151  *
152  * In the online version of SACLA input this should be thrown when
153  * the requested tag is outdated and not available anymore
154  */
155 class TagOutdated : public std::runtime_error
156 {
157 public:
158  /** explicit constructor
159  *
160  * @param message the error message
161  */
162  explicit TagOutdated(const std::string & message, bool thrown=true)
163  : std::runtime_error(message),
164  _wasThrown(thrown)
165  {}
166 
167  virtual ~TagOutdated() throw() {}
168 
169  operator bool()const {return _wasThrown;}
170 
171 private:
173 };
174 
175 
176 /** Exception thrown when there is an error with a SACLA Pixel Detector
177  *
178  * In case there is some error with a SACLA pixel detector this should be thrown
179  */
180 class SaclaPixDetError : public std::runtime_error
181 {
182 public:
183  /** explicit constructor
184  *
185  * @param message the error message
186  */
187  explicit SaclaPixDetError(const std::string & message, bool thrown=true)
188  : std::runtime_error(message),
189  _wasThrown(thrown)
190  {}
191 
192  virtual ~SaclaPixDetError() throw() {}
193 
194  operator bool()const {return _wasThrown;}
195 
196 private:
198 };
199 
200 }//end namespace cass
201 
202 #endif
TagOutdated(const std::string &message, bool thrown=true)
explicit constructor
InvalidData(const std::string &message)
explicit constructor
InvalidProcessorError(const std::string &key)
Exception thrown when a timeout occured.
Exception thrown when SACLA tag is outdated.
STL namespace.
Exception thrown when there is an error with a SACLA Pixel Detector.
RestartInputLoop(const std::string &message="")
explicit constructor
Exception thrown when there is a problem with the data.
Exception thrown when one needs to reastart the input loop.
SaclaPixDetError(const std::string &message, bool thrown=true)
explicit constructor
DeserializeError(const std::string &message)
explicit constructor
InvalidResultError(const std::string &name, uint64_t id)
Exception thrown when accessing invalid processor.
Exception thrown when there is a problem during data generation.
DataGenerationError(const std::string &message)
explicit constructor
Exception thrown when there is a problem with deserializing QDataStreams.
ProcessableTimedout(const std::string &message)
explicit constructor
Exception thrown when accessing invalid histogram.