All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ExceptionSink.h
/* -*- mode: c++; indent-tabs-mode: nil -*- */
/*
ExceptionSink.h
Qore Programming Language ExceptionSink class definition
Copyright (C) 2003 - 2015 David Nichols
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
Note that the Qore library is released under a choice of three open-source
licenses: MIT (as above), LGPL 2+, or GPL 2+; see README-LICENSE for more
information.
*/
#ifndef _QORE_EXCEPTIONSINK_H
#define _QORE_EXCEPTIONSINK_H
#include <stdarg.h>
#include <stdio.h>
class QoreException;
struct QoreProgramLocation;
class ExceptionSink {
friend struct qore_es_private;
private:
struct qore_es_private *priv;
DLLLOCAL ExceptionSink(const ExceptionSink&);
DLLLOCAL ExceptionSink& operator=(const ExceptionSink&);
public:
DLLEXPORT ExceptionSink();
DLLEXPORT ~ExceptionSink();
DLLEXPORT void handleExceptions();
DLLEXPORT void handleWarnings();
DLLEXPORT bool isEvent() const;
DLLEXPORT bool isThreadExit() const;
DLLEXPORT bool isException() const;
DLLEXPORT operator bool () const;
DLLEXPORT AbstractQoreNode *raiseException(const char *err, const char *fmt, ...);
DLLEXPORT AbstractQoreNode* raiseErrnoException(const char *err, int en, const char *fmt, ...);
DLLEXPORT AbstractQoreNode* raiseErrnoException(const char *err, int en, QoreStringNode* desc);
DLLEXPORT AbstractQoreNode *raiseExceptionArg(const char* err, AbstractQoreNode* arg, const char* fmt, ...);
DLLEXPORT AbstractQoreNode *raiseExceptionArg(const char* err, AbstractQoreNode* arg, QoreStringNode *desc);
DLLEXPORT AbstractQoreNode *raiseException(const char *err, QoreStringNode *desc);
DLLEXPORT void raiseThreadExit();
DLLEXPORT void assimilate(ExceptionSink *xs);
DLLEXPORT void assimilate(ExceptionSink &xs);
DLLEXPORT void outOfMemory();
DLLEXPORT void clear();
DLLLOCAL void raiseException(QoreException* e);
DLLLOCAL void raiseException(const QoreListNode* n);
DLLLOCAL void raiseException(const QoreProgramLocation& loc, const char* err, AbstractQoreNode* arg, AbstractQoreNode* desc);
DLLLOCAL void raiseException(const QoreProgramLocation& loc, const char* err, AbstractQoreNode* arg, const char* fmt, ...);
DLLLOCAL QoreException* catchException();
DLLLOCAL void overrideLocation(const QoreProgramLocation& loc);
DLLLOCAL void rethrow(QoreException* old);
DLLLOCAL static void defaultExceptionHandler(QoreException* e);
DLLLOCAL static void defaultWarningHandler(QoreException* e);
};
static inline void alreadyDeleted(ExceptionSink *xsink, const char *cmeth) {
xsink->raiseException("OBJECT-ALREADY-DELETED", "the method %s() cannot be executed because the object has already been deleted", cmeth);
}
static inline void makeAccessDeletedObjectException(ExceptionSink *xsink, const char *mem, const char *cname) {
xsink->raiseException("OBJECT-ALREADY-DELETED", "attempt to access member '%s' of an already-deleted object of class '%s'", mem, cname);
}
static inline void makeAccessDeletedObjectException(ExceptionSink *xsink, const char *cname) {
xsink->raiseException("OBJECT-ALREADY-DELETED", "attempt to access an already-deleted object of class '%s'", cname);
}
#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:55
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:50
QoreListNode
This is the list container type in Qore, dynamically allocated only, reference counted.
Definition: QoreListNode.h:52
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:43
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