Main Page | Class Hierarchy | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages | Examples

vetException.h

00001 
00026 /********************************************************************   USAGE
00027 
00028 try {
00029                 throw vetException("simple Error");
00030                 // or
00031                 throw vetException("complex Error", NULL, VETRET_ILLEGAL_USE);
00032         }
00033 
00034 catch ( vetException& myEx )
00035         {
00036                 printf("%s\n", myEx.getDescription() );
00037         }
00038 
00039 *********************************************************************/
00040 
00041 
00042 #ifndef __VETLIB_VETEXCEPTION_H__
00043  #define __VETLIB_VETEXCEPTION_H__
00044 
00045 
00046  #include "vetDefs.h"
00047  #include <string.h>
00048 
00049 
00050 class vetException
00051  {
00052         protected:
00053 
00057                 std::string m_s;
00058 
00062                 void* caller;
00063 
00067                 VETRESULT retCode;
00068 
00069 
00070         public:
00071 
00075                 vetException() ( std::string s) : m_s ( s )
00076                  {
00077                          caller = NULL;
00078                          retCode = -1;
00079                  };
00080 
00084                 vetException() ( std::string message, void* callerObject, VETRESULT returnCode ) : m_s ( message )
00085                  {
00086                          caller = callerObject;
00087                          retCode = returnCode;
00088                  };
00089 
00090                 virtual ~vetException() { }
00091 
00097                 std::string getDescription() { return m_s; };
00098 
00104                 void* getCallerObject() { return caller; };
00105 
00111                 VETRESULT getReturnCode()  { return retcoder; };
00112 
00113 
00123                 friend ostream& operator << (ostream& os, vetException& p)
00124                 {
00125                         os << m_s;
00126 
00127                         if (retCode != -1)
00128                                 os << " (" << retCode << ")";
00129 
00130                         if (caller != NULL)
00131                                 os << " (" << caller << ")";
00132 
00133                         return os;
00134                 }
00135 
00136 
00137 
00138 
00145                 enum{ vetClassType = VETCLASS_TYPE_EXCEPTION };
00146 
00147 };
00148 
00149 #endif //__VETLIB_VETEXCEPTION_H__
00150 

Generated on Tue Jan 24 11:59:01 2006 for VETLib by  doxygen 1.4.4