32#ifndef eman__exception_h__
33#define eman__exception_h__ 1
42using std::stringstream;
78 const string& desc_str =
"",
const string& objname_str =
"")
98 virtual const char *
what()
const throw();
103 virtual const
char *
name()
const {
return "Exception"; }
122 const string& file =
"unknown",
124 const string& desc_str =
"none")
125 :
E2Exception(file, line, desc_str, objname_str) {}
127 const char *
name()
const {
return "NotExistingObjectException"; }
130#define NotExistingObjectException(objname, desc) \
131 _NotExistingObjectException(objname, __FILE__, __LINE__, desc)
140 const string& file =
"unknown",
144 const char *
name()
const {
return "ImageFormatException"; }
147#define ImageFormatException(desc) _ImageFormatException(desc, __FILE__, __LINE__)
163 const char *
name()
const {
return "ImageDimensionException"; }
166#define ImageDimensionException(desc) _ImageDimensionException(desc, __FILE__, __LINE__)
178 int line = 0,
const string& desc_str =
"")
181 desc =
"cannot access file '" + filename_str +
"'";
184 const char *
name()
const {
return "FileAccessException"; }
187#define FileAccessException(filename) _FileAccessException(filename, __FILE__, __LINE__)
198 int line = 0,
const string& desc_str =
"")
201 const char *
name()
const {
return "ImageReadException"; }
204#define ImageReadException(filename, desc) \
205 _ImageReadException(filename, __FILE__, __LINE__, desc)
217 int line = 0,
const string& desc_str =
"")
220 const char *
name()
const {
return "ImageWriteException"; }
223#define ImageWriteException(imagename, desc) \
224 _ImageWriteException(imagename, __FILE__, __LINE__, desc)
235 int line = 0,
const string& desc_str =
"")
238 const char *
name()
const {
return "NullPointerException"; }
241#define NullPointerException(desc) _NullPointerException(__FILE__, __LINE__, desc)
255 const string & file =
"unknown",
int line = 0)
258 const char *
name()
const {
return "TypeException"; }
261#define TypeException(desc, type) _TypeException(desc, type, __FILE__, __LINE__)
274 int line = 0,
const string& desc_str =
"")
281 const char *
name()
const {
return "InvalidValueException"; }
285#define InvalidValueException(val, desc) \
286 _InvalidValueException(val, __FILE__, __LINE__, desc)
298 int line = 0,
const string& desc_str =
"")
303 const char *
name()
const {
return "InvalidStringException"; }
306#define InvalidStringException(str, desc) \
307 _InvalidStringException(str, __FILE__, __LINE__, desc)
321 const string& file =
"unknown",
322 int line = 0,
const string & desc_str =
"",
323 const string& objname_str =
"")
327 ss << input <<
" out of range [" << low <<
"," << high <<
"]";
331 const char *
name()
const {
return "OutofRangeException"; }
334#define OutofRangeException(low, high, input, objname) \
335 _OutofRangeException(low, high, input, __FILE__, __LINE__, objname)
342 int line = 0,
const string& desc_str =
"")
345 const char *
name()
const {
return "InvalidCallException"; }
348#define InvalidCallException(desc) _InvalidCallException(__FILE__, __LINE__, desc)
356 int line = 0,
const string& desc_str =
"")
359 const char *
name()
const {
return "InvalidParameterException"; }
361#define InvalidParameterException(desc) _InvalidParameterException(__FILE__, __LINE__, desc)
369 int line = 0,
const string& desc_str =
"")
372 const char *
name()
const {
return "EmptyContainerException"; }
374#define EmptyContainerException(desc) _EmptyContainerException(__FILE__, __LINE__, desc)
382 int line = 0,
const string& desc_str =
"")
385 const char *
name()
const {
return "BadAllocException"; }
387#define BadAllocException(desc) _BadAllocException(__FILE__, __LINE__, desc)
395 int line = 0,
const string& desc_str =
"")
398 const char *
name()
const {
return "UnexpectedBehaviorException"; }
400#define UnexpectedBehaviorException(desc) _UnexpectedBehaviorException(__FILE__, __LINE__, desc)
E2Exception class is the parent class of all EMAN2 E2Exceptions.
virtual const char * what() const
The E2Exception information.
virtual const char * name() const
The name of this E2Exception class.
E2Exception(const string &file="", int line=0, const string &desc_str="", const string &objname_str="")
Contructor.
Used when memory allocation goes wrong... i.e.
const char * name() const
The name of this E2Exception class.
_BadAllocException(const string &file="unknown", int line=0, const string &desc_str="")
Used when an argument container is empty, such as a vector.
const char * name() const
The name of this E2Exception class.
_EmptyContainerException(const string &file="unknown", int line=0, const string &desc_str="")
Used when a file access error occurs.
_FileAccessException(const string &filename_str, const string &file="unknown", int line=0, const string &desc_str="")
const char * name() const
The name of this E2Exception class.
Used when an image is not in the expected dimension.
const char * name() const
The name of this E2Exception class.
_ImageDimensionException(const string &desc_str, const string &file="unknown", int line=0)
Used when an error occurs at image reading time.
_ImageReadException(const string &imagename, const string &file="unknown", int line=0, const string &desc_str="")
const char * name() const
The name of this E2Exception class.
Used when an error occurs at image writing time.
_ImageWriteException(const string &imagename, const string &file="unknown", int line=0, const string &desc_str="")
const char * name() const
The name of this E2Exception class.
_InvalidCallException(const string &file="unknown", int line=0, const string &desc_str="")
const char * name() const
The name of this E2Exception class.
_InvalidParameterException(const string &file="unknown", int line=0, const string &desc_str="")
const char * name() const
The name of this E2Exception class.
Used when an invalid (format) string is given.
_InvalidStringException(const string &str, const string &file="unknown", int line=0, const string &desc_str="")
const char * name() const
The name of this E2Exception class.
Used when an invalid integer value is given.
const char * name() const
The name of this E2Exception class.
_InvalidValueException(T val, const string &file="unknown", int line=0, const string &desc_str="")
Used when an object type, like an EMObject type, doesn't exist.
const char * name() const
The name of this E2Exception class.
_NotExistingObjectException(const string &objname_str, const string &file="unknown", int line=0, const string &desc_str="none")
Used when a NULL is given to a pointer that should not be NULL.
_NullPointerException(const string &file="unknown", int line=0, const string &desc_str="")
const char * name() const
The name of this E2Exception class.
Used when the given value is out of range.
const char * name() const
The name of this E2Exception class.
_OutofRangeException(int low, int high, int input, const string &file="unknown", int line=0, const string &desc_str="", const string &objname_str="")
Used when a type cast error occurs.
_TypeException(const string &desc_str, const string &type, const string &file="unknown", int line=0)
const char * name() const
The name of this E2Exception class.
Used when internal behavior is unexpected A generic kind of exception.
_UnexpectedBehaviorException(const string &file="unknown", int line=0, const string &desc_str="")
const char * name() const
The name of this E2Exception class.