00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef _QORE_EXCEPTIONSINK_H
00025
00026 #define _QORE_EXCEPTIONSINK_H
00027
00028 #include <stdarg.h>
00029 #include <stdio.h>
00030
00031 class QoreException;
00032
00034 class ExceptionSink {
00035 private:
00037 struct qore_es_private *priv;
00038
00039 DLLLOCAL void insert(QoreException *e);
00040 DLLLOCAL void clearIntern();
00041
00043 DLLLOCAL ExceptionSink(const ExceptionSink&);
00044
00046 DLLLOCAL ExceptionSink& operator=(const ExceptionSink&);
00047
00048 public:
00050 DLLEXPORT ExceptionSink();
00051
00053 DLLEXPORT ~ExceptionSink();
00054
00056 DLLEXPORT void handleExceptions();
00057
00059 DLLEXPORT void handleWarnings();
00060
00062 DLLEXPORT bool isEvent() const;
00063
00065 DLLEXPORT bool isThreadExit() const;
00066
00068 DLLEXPORT bool isException() const;
00069
00071
00077 DLLEXPORT operator bool () const;
00078
00080
00085 DLLEXPORT AbstractQoreNode *raiseException(const char *err, const char *fmt, ...);
00086
00088
00094 DLLEXPORT AbstractQoreNode *raiseErrnoException(const char *err, int en, const char *fmt, ...);
00095
00097
00103 DLLEXPORT AbstractQoreNode *raiseExceptionArg(const char* err, AbstractQoreNode* arg, const char* fmt, ...);
00104
00106
00112 DLLEXPORT AbstractQoreNode *raiseExceptionArg(const char* err, AbstractQoreNode* arg, QoreStringNode *desc);
00113
00115
00120 DLLEXPORT AbstractQoreNode *raiseException(const char *err, QoreStringNode *desc);
00121
00123 DLLEXPORT void raiseThreadExit();
00124
00126 DLLEXPORT void assimilate(ExceptionSink *xs);
00127
00129 DLLEXPORT void outOfMemory();
00130
00132 DLLEXPORT void clear();
00133
00134 DLLLOCAL void raiseException(QoreException *e);
00135 DLLLOCAL void raiseException(const QoreListNode *n);
00136 DLLLOCAL QoreException *catchException();
00137 DLLLOCAL void overrideLocation(int sline, int eline, const char *file);
00138 DLLLOCAL void rethrow(QoreException *old);
00139 DLLLOCAL void addStackInfo(int type, const char *class_name, const char *code, const char *file, int start_line, int end_line);
00140 DLLLOCAL void addStackInfo(int type, const char *class_name, const char *code);
00141
00142 DLLLOCAL static void defaultExceptionHandler(QoreException *e);
00143 DLLLOCAL static void defaultWarningHandler(QoreException *e);
00144 };
00145
00146
00147 static inline void alreadyDeleted(ExceptionSink *xsink, const char *cmeth) {
00148 xsink->raiseException("OBJECT-ALREADY-DELETED", "the method %s() cannot be executed because the object has already been deleted", cmeth);
00149 }
00150
00151 static inline void makeAccessDeletedObjectException(ExceptionSink *xsink, const char *mem, const char *cname) {
00152 xsink->raiseException("OBJECT-ALREADY-DELETED", "attempt to access member '%s' of an already-deleted object of class '%s'", mem, cname);
00153 }
00154
00155 static inline void makeAccessDeletedObjectException(ExceptionSink *xsink, const char *cname) {
00156 xsink->raiseException("OBJECT-ALREADY-DELETED", "attempt to access an already-deleted object of class '%s'", cname);
00157 }
00158
00159 #endif