stromx  0.8.0
Exception.h
1 /*
2  * Copyright 2011 Matthias Fuchs
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef STROMX_RUNTIME_EXCEPTION_H
18 #define STROMX_RUNTIME_EXCEPTION_H
19 
20 #include <exception>
21 #include <string>
22 #include "stromx/runtime/Config.h"
23 
24 namespace stromx
25 {
26  namespace runtime
27  {
28  class Data;
29 
31  class STROMX_RUNTIME_API Exception : public std::exception
32  {
33  public:
35  explicit Exception(const std::string & message);
36 
37  virtual ~Exception() throw() {}
38 
39  virtual const char* what() const throw() { return m_message.c_str(); }
40 
42  virtual const std::string & message() const { return m_message; }
43 
45  virtual const std::string & callStack() const { return m_callStack; }
46 
47  private:
48  std::string m_message;
49  std::string m_callStack;
50  };
51 
53  class WrongArgument : public Exception
54  {
55  public:
56  WrongArgument(const std::string & message = "WrongArgument")
57  : Exception(message)
58  {}
59  };
60 
62  class WrongId : public WrongArgument
63  {
64  public:
65  WrongId(const std::string & message = "WrongId")
66  : WrongArgument(message)
67  {}
68  };
69 
71  class WrongState : public Exception
72  {
73  public:
74  WrongState(const std::string & message = "WrongState")
75  : Exception(message)
76  {}
77  };
78 
80  class InternalError : public Exception
81  {
82  public:
83  InternalError(const std::string & message = "InternalError")
84  : Exception(message)
85  {}
86  };
87 
89  class Interrupt : public Exception
90  {
91  public:
92  Interrupt(const std::string & message = "Interrupt")
93  : Exception(message)
94  {}
95  };
96 
98  class FileException : public Exception
99  {
100  public:
101  FileException(const std::string & filename, const std::string & container,
102  const std::string & message)
103  : Exception(message),
104  m_filename(filename),
105  m_container(container)
106  {}
107 
108  virtual ~FileException() throw() {}
109 
110  const std::string & filename() const { return m_filename; }
111  const std::string & container() const { return m_container; }
112 
113  void setContainer(const std::string & container) { m_container = container; }
114 
115  private:
116  const std::string m_filename;
117  std::string m_container;
118  };
119 
122  {
123  public:
124 
125  FileAccessFailed(const std::string & filename,
126  const std::string & container,
127  const std::string & message = "")
128  : FileException(filename, container, message)
129  {}
130  };
131 
134  {
135  public:
136  InvalidFileFormat(const std::string & filename,
137  const std::string & message)
138  : FileException(filename, "", message)
139  {}
140 
141  InvalidFileFormat(const std::string & filename,
142  const std::string & container,
143  const std::string & message)
144  : FileException(filename, container, message)
145  {}
146  };
147 
150  {
151  public:
152  InconsistentFileContent(const std::string & filename,
153  const std::string & message)
154  : FileException(filename, "", message)
155  {}
156 
157  InconsistentFileContent(const std::string & filename,
158  const std::string & container,
159  const std::string & message)
160  : FileException(filename, container, message)
161  {}
162  };
163 
165  class OutOfMemory : public Exception
166  {
167  public:
168  OutOfMemory(const std::string & message = "OutOfMemory")
169  : Exception(message)
170  {}
171  };
172 
174  class Timeout : public Exception
175  {
176  public:
177  Timeout(const std::string & message = "Timeout")
178  : Exception(message)
179  {}
180  };
181 
183  class BadCast : public Exception
184  {
185  public:
186  BadCast(const std::string & message = "BadCast")
187  : Exception(message)
188  {}
189  };
190 
192  class NotImplemented : public Exception
193  {
194  public:
195  NotImplemented(const std::string & message = "NotImplemented")
196  : Exception(message)
197  {}
198  };
199 
201  class AccessEmpty : public Exception
202  {
203  public:
204  AccessEmpty(const std::string & message = "AccessEmpty")
205  : Exception(message)
206  {}
207  };
208 
210  class DataException : public Exception
211  {
212  public:
213 
214  virtual ~DataException() throw() {}
215 
216  const std::string & package() const { return m_package; }
217  const std::string & type() const { return m_package; }
218 
219  protected:
220  DataException(const std::string & package, const std::string & type,
221  const std::string & message = "DataException")
222  : Exception(message),
223  m_package(package),
224  m_type(type)
225  {}
226 
227  private:
228  const std::string m_package;
229  const std::string m_type;
230  };
231 
234  {
235  public:
236  SerializationError(const std::string & package, const std::string & type,
237  const std::string & message = "SerializationError")
238  : DataException(package, type, message)
239  {}
240  };
241 
244  {
245  public:
246  DeserializationError(const std::string & package, const std::string & type,
247  const std::string & message = "DeserializationError")
248  : DataException(package, type, message)
249  {}
250  };
251 
254  {
255  public:
256 
257  virtual ~FactoryException() throw() {}
258 
259  const std::string & package() const { return m_package; }
260  const std::string & type() const { return m_type; }
261 
262  protected:
263  FactoryException(const std::string & package, const std::string & type,
264  const std::string & message = "SerializationError")
265  : Exception(message),
266  m_package(package),
267  m_type(type)
268  {}
269 
270  private:
271  const std::string m_package;
272  const std::string m_type;
273  };
274 
277  {
278  public:
279  OperatorAllocationFailed(const std::string & package, const std::string & type,
280  const std::string & message = "OperatorAllocationFailed")
281  : FactoryException(package, type, message)
282  {}
283  };
284 
287  {
288  public:
289  DataAllocationFailed(const std::string & package, const std::string & type,
290  const std::string & message = "DataAllocationFailed")
291  : FactoryException(package, type, message)
292  {}
293  };
294 
296  class NoInputFile : public Exception
297  {
298  public:
299  NoInputFile(const std::string & message = "NoInputFile")
300  : Exception(message)
301  {}
302  };
303  }
304 }
305 
306 #endif // STROMX_RUNTIME_EXCEPTION_H
Data could not be serialized.
Definition: Exception.h:233
virtual const std::string & callStack() const
Definition: Exception.h:45
Tried to get the data of an empty read or write access.
Definition: Exception.h:201
Not enought memory.
Definition: Exception.h:165
An object was identified by a wrong ID.
Definition: Exception.h:62
The file format is invalid.
Definition: Exception.h:133
Error related to a Data object.
Definition: Exception.h:210
An operation timed out.
Definition: Exception.h:174
A file related exception.
Definition: Exception.h:98
The file content is not consistent.
Definition: Exception.h:149
Data could not be allocated.
Definition: Exception.h:286
The stromx class library.
Definition: AdjustRgbChannels.cpp:29
Error related to a data and operator factory.
Definition: Exception.h:253
The input provider has no input file.
Definition: Exception.h:296
An internal, unexpected error occurred.
Definition: Exception.h:80
A wrong argument was passed to a function.
Definition: Exception.h:53
A function which is not implemented was called.
Definition: Exception.h:192
Data could not be deserialized.
Definition: Exception.h:243
Abstract stromx exception.
Definition: Exception.h:31
The current state does not allow a specific operation.
Definition: Exception.h:71
The current thread was stopped.
Definition: Exception.h:89
An error occurred during file access.
Definition: Exception.h:121
virtual const std::string & message() const
Definition: Exception.h:42
An impossible cast was attempted.
Definition: Exception.h:183
Operator could not be allocated.
Definition: Exception.h:276