EMAN2 Exception FAQ


1. How to use an exception in general?


2. What are the existing Exception types in EMAN2?

Exception Name
  Parameters     
Description
E2Exception
                                   
E2Exception class is the parent class of all EMAN2 E2Exceptions. You may use it to catch any EMAN2 exception. You shouldn't throw any E2Exception in your code.
FileAccessException string filename;
Used when a file access error occurs. For example, when you  try to open a non-existing file or directory.
ImageDimensionException string desc;
Used when an image is not in the expected dimension. For example, a 2D image is given when a 3D image is expected.
ImageFormatException string desc;
Used when an image is not in the expected format.
ImageReadException string imagename;
string desc;
Used when an error occurs at image reading time.
ImageWriteException string imagename;
string desc;
Used when an error occurs at image writing time.
InvalidValueException
int value;
int desc;
Used when an invalid integer value is given.
NotExistingObjectException string objectname;
string desc;
Used when an object type, like an EMObject type, doesn't exist.
NullPointerException string desc;
Used when a NULL is given to a pointer that should not be NULL.
OutofRangeException int low;
int high;
int input;
int objectname;
Used when the given value is out of range.
TypeException string desc;
string type;
Used when a type cast error occurs. For example, when casting an EMData* type to a float type.



3. How to define a new XYZ Exception class?



  class _NullPointerException : public E2Exception

  {
  public:
        _NullPointerException(const string& file = "unknown",
                              int line = 0, const string& desc_str = "")
            : E2Exception(file, line, desc_str) {}
       
        const char *name() const { return "NullPointerException"; }
       
  };

 
#define NullPointerException(desc) _NullPointerException(__FILE__, __LINE__,desc)







Last modified on 12/07/2004 by Liwei Peng (lpeng@bcm.tmc.edu)