00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _QORE_EXCEPTIONSINK_H
00024
00025 #define _QORE_EXCEPTIONSINK_H
00026
00027 #include <stdarg.h>
00028 #include <stdio.h>
00029
00030 class QoreException;
00031
00033 class ExceptionSink {
00034 private:
00036 struct qore_es_private *priv;
00037
00038 DLLLOCAL void insert(QoreException *e);
00039 DLLLOCAL void clearIntern();
00040
00042 DLLLOCAL ExceptionSink(const ExceptionSink&);
00043
00045 DLLLOCAL ExceptionSink& operator=(const ExceptionSink&);
00046
00047 public:
00049 DLLEXPORT ExceptionSink();
00050
00052 DLLEXPORT ~ExceptionSink();
00053
00055 DLLEXPORT void handleExceptions();
00056
00058 DLLEXPORT void handleWarnings();
00059
00061 DLLEXPORT bool isEvent() const;
00062
00064 DLLEXPORT bool isThreadExit() const;
00065
00067 DLLEXPORT bool isException() const;
00068
00070
00076 DLLEXPORT operator bool () const;
00077
00079
00084 DLLEXPORT class AbstractQoreNode *raiseException(const char *err, const char *fmt, ...);
00085
00087
00093 DLLEXPORT AbstractQoreNode* raiseExceptionArg(const char* err, AbstractQoreNode* arg, const char* fmt, ...);
00094
00096
00101 DLLEXPORT AbstractQoreNode *raiseException(const char *err, QoreStringNode *desc);
00102
00104 DLLEXPORT void raiseThreadExit();
00105
00107 DLLEXPORT void assimilate(ExceptionSink *xs);
00108
00110 DLLEXPORT void outOfMemory();
00111
00113 DLLEXPORT void clear();
00114
00115 DLLLOCAL void raiseException(QoreException *e);
00116 DLLLOCAL void raiseException(const class QoreListNode *n);
00117 DLLLOCAL QoreException *catchException();
00118 DLLLOCAL void overrideLocation(int sline, int eline, const char *file);
00119 DLLLOCAL void rethrow(QoreException *old);
00120 DLLLOCAL void addStackInfo(int type, const char *class_name, const char *code, const char *file, int start_line, int end_line);
00121 DLLLOCAL void addStackInfo(int type, const char *class_name, const char *code);
00122
00123 DLLLOCAL static void defaultExceptionHandler(QoreException *e);
00124 DLLLOCAL static void defaultWarningHandler(QoreException *e);
00125 };
00126
00127
00128 static inline void alreadyDeleted(ExceptionSink *xsink, const char *cmeth)
00129 {
00130 xsink->raiseException("OBJECT-ALREADY-DELETED", "the method %s() cannot be executed because the object has already been deleted", cmeth);
00131 }
00132
00133 static inline void makeAccessDeletedObjectException(ExceptionSink *xsink, const char *mem, const char *cname)
00134 {
00135 xsink->raiseException("OBJECT-ALREADY-DELETED", "attempt to access member '%s' of an already-deleted object of class '%s'", mem, cname);
00136 }
00137
00138 static inline void makeAccessDeletedObjectException(ExceptionSink *xsink, const char *cname)
00139 {
00140 xsink->raiseException("OBJECT-ALREADY-DELETED", "attempt to access an already-deleted object of class '%s'", cname);
00141 }
00142
00143 #endif