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 2003 - 2013 David Nichols
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#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