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/OSRTContext.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
00041 #define OSSAXTHROW throw OSSAXException ()
00042
00043 #define OSSAXTHROWSTR(ctxt,str) \
00044 throw OSSAXException (ctxt,str,RTERR_XMLPARSE,(const OSUTF8CHAR*)__FILE__, __LINE__)
00045
00046 #define OSSAXTHROWSTATUS(ctxt,stat) \
00047 throw OSSAXException (ctxt,LOG_RTERR(ctxt->getPtr(),stat),(const OSUTF8CHAR*)__FILE__, __LINE__)
00048
00049 #else
00050 #define OSTRY
00051 #define OSRTLTHROW1(stat) do { \
00052 fprintf (stderr, "Fatal Error in %s at %i, stat = %i\n", __FILE__, __LINE__, stat); \
00053 exit (-1); \
00054 } while(0)
00055 #define OSRTLTHROW2(ctxt,stat) do { \
00056 rtxErrPrint (ctxt); \
00057 fprintf (stderr, "Fatal Error in %s at %i, stat = %i\n", __FILE__, __LINE__, stat); \
00058 exit (-1); \
00059 } while(0)
00060
00061 #define OSTHROW(ex) do { \
00062 fprintf (stderr, "Fatal Error in %s at %i\n", __FILE__, __LINE__); \
00063 exit (-1); \
00064 } while (0)
00065 #define OSCATCH(exType,ex,body)
00066
00067 #define OSSAXTHROW { \
00068 fprintf (stderr, "Fatal Error, OSSAXException is thrown, in %s at %i\n", \
00069 __FILE__, __LINE__); \
00070 exit (-1); \
00071 }
00072 #define OSSAXTHROWSTR(ctxt,str) { \
00073 fprintf (stderr, "Fatal Error, OSSAXException(%s) is thrown, in %s at %i\n", \
00074 str, __FILE__, __LINE__); \
00075 exit (-1); \
00076 }
00077
00078 #define OSSAXTHROWSTATUS(ctxt,stat) { \
00079 fprintf (stderr, "Fatal Error, OSSAXException(status = %i) is thrown, in %s at %i\n", \
00080 stat, __FILE__, __LINE__); \
00081 exit (-1); \
00082 }
00083 #endif
00084
00088 class EXTRTCLASS OSRTLException {
00089 protected:
00090 OSRTCtxtPtr mpContext;
00091
00096 int mStatus;
00097
00098 inline OSRTLException () : mStatus(0) {}
00099
00100 public:
00107 inline OSRTLException (int stat) : mStatus(stat) {}
00108
00116 inline OSRTLException (OSRTContext* pContext, int stat) :
00117 mpContext (pContext), mStatus(stat) {}
00118
00124 inline OSRTLException (const OSRTLException& o) :
00125 mpContext (o.mpContext), mStatus(o.mStatus) {}
00126
00131 inline ~OSRTLException () {}
00132
00136 inline int getStatus () const { return (mStatus); }
00137
00141 inline void printErrorInfo () {}
00142 } ;
00143
00147 class EXTRTCLASS OSStreamException : public OSRTLException {
00148 public:
00150 inline OSStreamException (int stat) : OSRTLException(stat) {}
00151
00153 inline OSStreamException (OSRTContext* pContext, int stat) :
00154 OSRTLException(pContext, stat) {}
00155
00157 inline OSStreamException (const OSStreamException& o) :
00158 OSRTLException(o) {}
00159 } ;
00160
00161 class EXTRTCLASS OSSAXException : public OSRTLException
00162 {
00163 public:
00167 inline OSSAXException() {}
00168
00174 inline OSSAXException(OSRTContext* pContext, const OSUTF8CHAR* const msg) {}
00175
00186 inline OSSAXException(OSRTContext* pContext, const OSUTF8CHAR* const msg,
00187 int stat_, const OSUTF8CHAR* const file_, int line_) {}
00188
00198 inline OSSAXException(OSRTContext* pContext, int stat_,
00199 const OSUTF8CHAR* file_, int line_) {}
00200
00206 inline OSSAXException(const OSSAXException& toCopy) :
00207 OSRTLException (toCopy) {}
00208
00210 inline ~OSSAXException() {}
00211
00212 inline const OSUTF8CHAR* getMessage() { return (const OSUTF8CHAR*)""; }
00213
00214 inline const OSUTF8CHAR* getSrcFileName () { return (const OSUTF8CHAR*)""; }
00215 inline int getSrcLineNum() { return -1; }
00216
00217 inline void printErrorInfo () {}
00218
00219 protected :
00220 const OSUTF8CHAR* mpMsg;
00221 const OSUTF8CHAR* mpFile;
00222 int line;
00223 };
00224
00225 #endif