00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00028 #ifndef _RTXCPPEXCEPTION_H_
00029 #define _RTXCPPEXCEPTION_H_
00030
00031 #include "rtxsrc/rtxCommon.h"
00032 #include "rtxsrc/rtxCppContext.h"
00033
00034 #ifndef _NO_EXCEPTIONS
00035 #define OSTRY try
00036 #define OSRTLTHROW1(stat) throw OSRTLException(stat)
00037 #define OSRTLTHROW2(ctxt,stat) throw OSRTLException(ctxt,stat)
00038 #define OSTHROW(ex) throw (ex)
00039 #define OSCATCH(exType,ex,body) catch (exType ex) { body; }
00040 #else
00041 #define OSTRY
00042 #define OSRTLTHROW1(stat) do { \
00043 fprintf (stderr, "Fatal Error in %s at %i, stat = %i\n", __FILE__, __LINE__, stat); \
00044 exit (-1); \
00045 } while(0)
00046 #define OSRTLTHROW2(ctxt,stat) do { \
00047 rtxErrPrint (ctxt); \
00048 fprintf (stderr, "Fatal Error in %s at %i, stat = %i\n", __FILE__, __LINE__, stat); \
00049 exit (-1); \
00050 } while(0)
00051
00052 #define OSTHROW(ex) do { \
00053 fprintf (stderr, "Fatal Error in %s at %i\n", __FILE__, __LINE__); \
00054 exit (-1); \
00055 } while (0)
00056 #define OSCATCH(exType,ex,body)
00057 #endif
00058
00062 class EXTERNRTX OSRTLException {
00063 protected:
00064 OSCtxtPtr mpContext;
00065
00070 int mStatus;
00071
00072 OSRTLException () : mStatus(0) {}
00073
00074 public:
00081 OSRTLException (int stat) : mStatus(stat) {}
00082
00090 OSRTLException (OSContext* pContext, int stat) :
00091 mpContext (pContext), mStatus(stat) {}
00092
00098 OSRTLException (const OSRTLException& o) :
00099 mpContext (o.mpContext), mStatus(o.mStatus) {}
00100
00105 virtual ~OSRTLException () {}
00106
00110 int getStatus () const { return (mStatus); }
00111
00115 void printErrorInfo ();
00116 } ;
00117
00118 #endif