Qore Programming Language 0.8.8

- Main Page
- Related Pages
- Modules
- Classes
- Files

- File List
- File Members

All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ExceptionSink.h
1 /* -*- mode: c++; indent-tabs-mode: nil -*- */
2 /*
3 ExceptionSink.h
4
5 Qore Programming Language ExceptionSink class definition
6
7 Copyright 2003 - 2013 David Nichols
8
9 This library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Lesser General Public
11 License as published by the Free Software Foundation; either
12 version 2.1 of the License, or (at your option) any later version.
13
14 This library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public
20 License along with this library; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
24 #ifndef _QORE_EXCEPTIONSINK_H
25
26 #define _QORE_EXCEPTIONSINK_H
27
28 #include <stdarg.h>
29 #include <stdio.h>
30
31 class QoreException;
32 struct QoreProgramLocation;
33
35 class ExceptionSink {
36 friend struct qore_es_private;
37
38 private:
40 struct qore_es_private *priv;
41
43 DLLLOCAL ExceptionSink(const ExceptionSink&);
44
46 DLLLOCAL ExceptionSink& operator=(const ExceptionSink&);
47
48 public:
50 DLLEXPORT ExceptionSink();
51
53 DLLEXPORT ~ExceptionSink();
54
56 DLLEXPORT void handleExceptions();
57
59 DLLEXPORT void handleWarnings();
60
62 DLLEXPORT bool isEvent() const;
63
65 DLLEXPORT bool isThreadExit() const;
66
68 DLLEXPORT bool isException() const;
69
71
77 DLLEXPORT operator bool () const;
78
80
85 DLLEXPORT AbstractQoreNode *raiseException(const char *err, const char *fmt, ...);
86
88
94 DLLEXPORT AbstractQoreNode* raiseErrnoException(const char *err, int en, const char *fmt, ...);
95
97
103 DLLEXPORT AbstractQoreNode* raiseErrnoException(const char *err, int en, QoreStringNode* desc);
104
106
112 DLLEXPORT AbstractQoreNode *raiseExceptionArg(const char* err, AbstractQoreNode* arg, const char* fmt, ...);
113
115
121 DLLEXPORT AbstractQoreNode *raiseExceptionArg(const char* err, AbstractQoreNode* arg, QoreStringNode *desc);
122
124
129 DLLEXPORT AbstractQoreNode *raiseException(const char *err, QoreStringNode *desc);
130
132 DLLEXPORT void raiseThreadExit();
133
135 DLLEXPORT void assimilate(ExceptionSink *xs);
136
138 DLLEXPORT void assimilate(ExceptionSink &xs);
139
141 DLLEXPORT void outOfMemory();
142
144 DLLEXPORT void clear();
145
146 DLLLOCAL void raiseException(QoreException* e);
147 DLLLOCAL void raiseException(const QoreListNode* n);
148 DLLLOCAL void raiseException(const QoreProgramLocation& loc, const char* err, AbstractQoreNode* arg, AbstractQoreNode* desc);
149 DLLLOCAL void raiseException(const QoreProgramLocation& loc, const char* err, AbstractQoreNode* arg, const char* fmt, ...);
150 DLLLOCAL QoreException* catchException();
151 DLLLOCAL void overrideLocation(const QoreProgramLocation& loc);
152 DLLLOCAL void rethrow(QoreException* old);
153
154 DLLLOCAL static void defaultExceptionHandler(QoreException* e);
155 DLLLOCAL static void defaultWarningHandler(QoreException* e);
156 };
157
158 static inline void alreadyDeleted(ExceptionSink *xsink, const char *cmeth) {
159 xsink->raiseException("OBJECT-ALREADY-DELETED", "the method %s() cannot be executed because the object has already been deleted", cmeth);
160 }
161
162 static inline void makeAccessDeletedObjectException(ExceptionSink *xsink, const char *mem, const char *cname) {
163 xsink->raiseException("OBJECT-ALREADY-DELETED", "attempt to access member '%s' of an already-deleted object of class '%s'", mem, cname);
164 }
165
166 static inline void makeAccessDeletedObjectException(ExceptionSink *xsink, const char *cname) {
167 xsink->raiseException("OBJECT-ALREADY-DELETED", "attempt to access an already-deleted object of class '%s'", cname);
168 }
169
170 #endif
ExceptionSink::handleWarnings
DLLEXPORT void handleWarnings()
calls ExceptionSink::defaultWarningHandler() on all exceptions still present in the object and then d...
ExceptionSink::outOfMemory
DLLEXPORT void outOfMemory()
intended to be used to handle out of memory errors FIXME: not yet fully implemented ...
ExceptionSink::~ExceptionSink
DLLEXPORT ~ExceptionSink()
calls ExceptionSink::defaultExceptionHandler() on all exceptions still present in the object and then...
ExceptionSink::handleExceptions
DLLEXPORT void handleExceptions()
calls ExceptionSink::defaultExceptionHandler() on all exceptions still present in the object and then...
ExceptionSink::isEvent
DLLEXPORT bool isEvent() const
returns true if at least one exception is present or thread_exit has been triggered ...
AbstractQoreNode
The base class for all value and parse types in Qore expression trees.
Definition: AbstractQoreNode.h:47
ExceptionSink::raiseException
DLLEXPORT AbstractQoreNode * raiseException(const char *err, const char *fmt,...)
appends a Qore-language exception to the list
ExceptionSink::raiseErrnoException
DLLEXPORT AbstractQoreNode * raiseErrnoException(const char *err, int en, const char *fmt,...)
appends a Qore-language exception to the list and appends the result of strerror(errno) to the descri...
QoreStringNode
Qore&#39;s string value type, reference counted, dynamically-allocated only.
Definition: QoreStringNode.h:40
QoreListNode
This is the list container type in Qore, dynamically allocated only, reference counted.
Definition: QoreListNode.h:44
ExceptionSink::isThreadExit
DLLEXPORT bool isThreadExit() const
returns true if thread_exit has been triggered
ExceptionSink::raiseExceptionArg
DLLEXPORT AbstractQoreNode * raiseExceptionArg(const char *err, AbstractQoreNode *arg, const char *fmt,...)
appends a Qore-language exception to the list, and sets the &#39;arg&#39; member (this object takes over the ...
ExceptionSink::clear
DLLEXPORT void clear()
deletes the exception list immediately
ExceptionSink
container for holding Qore-language exception information and also for registering a &quot;thread_exit&quot; ca...
Definition: ExceptionSink.h:35
ExceptionSink::raiseThreadExit
DLLEXPORT void raiseThreadExit()
sets the &quot;thread_exit&quot; flag; will cause the current thread to terminate
ExceptionSink::ExceptionSink
DLLEXPORT ExceptionSink()
creates an empty ExceptionSink object
ExceptionSink::assimilate
DLLEXPORT void assimilate(ExceptionSink *xs)
assimilates all entries of the &quot;xs&quot; argument by appending them to the internal list and deletes the &quot;...
ExceptionSink::isException
DLLEXPORT bool isException() const
returns true if at least one exception is present