32 #ifndef _QORE_EXCEPTIONSINK_H    34 #define _QORE_EXCEPTIONSINK_H    42 hashdecl QoreProgramLocation;
    47     friend hashdecl qore_es_private;
    51     hashdecl qore_es_private *priv;
    57     DLLLOCAL ExceptionSink& operator=(
const ExceptionSink&);
    88     DLLEXPORT 
operator bool () 
const;
   210     DLLEXPORT 
void raiseException(
const QoreProgramLocation& loc, 
const char* err, 
QoreValue arg, 
const char* fmt, ...);
   225     DLLEXPORT 
void clear();
   245     DLLLOCAL QoreException* catchException();
   246     DLLLOCAL QoreException* getException();
   247     DLLLOCAL 
void overrideLocation(
const QoreProgramLocation& loc);
   248     DLLLOCAL 
void rethrow(QoreException* old);
   250     DLLLOCAL 
static void defaultExceptionHandler(QoreException* e);
   251     DLLLOCAL 
static void defaultWarningHandler(QoreException* e);
   253     DLLLOCAL 
static void outputExceptionLocation(
const char* fns, 
int start_line, 
int end_line, 
const char* srcs,
   254         int offset, 
const char* langs, 
const char* types);
   258 enum qore_call_t : 
signed char {
   278     DLLLOCAL 
QoreSourceLocation(
const char* label, 
int start, 
int end, 
const char* code, 
const char* lang = 
"Qore") :
   279         label(label), start_line(start), end_line(end), code(code), lang(lang) {
   282     DLLLOCAL 
QoreSourceLocation(
const char* label, 
int start, 
int end, 
const char* source, 
unsigned offset,
   283         const char* code, 
const char* lang = 
"Qore") :
   284         label(label), start_line(start), end_line(end), source(source), offset(offset), code(code), lang(lang) {
   294     DLLLOCAL 
QoreCallStackElement(qore_call_t type, 
const char* label, 
int start, 
int end, 
const char* code,
   295         const char* lang = 
"Qore") :
   299     DLLLOCAL 
QoreCallStackElement(qore_call_t type, 
const char* label, 
int start, 
int end, 
const char* source,
   300         unsigned offset, 
const char* code, 
const char* lang = 
"Qore") :
   305 typedef std::vector<QoreCallStackElement> callstack_vec_t;
   311     DLLLOCAL 
void add(qore_call_t type, 
const char* label, 
int start, 
int end, 
const char* code,
   312         const char* lang = 
"Qore") {
   316     DLLLOCAL 
void add(qore_call_t type, 
const char* label, 
int start, 
int end, 
const char* source,
   317         unsigned offset, 
const char* code, 
const char* lang = 
"Qore") {
   322 static inline void alreadyDeleted(
ExceptionSink *xsink, 
const char *cmeth) {
   323     xsink->
raiseException(
"OBJECT-ALREADY-DELETED", 
"the method %s() cannot be executed because the object has already been deleted", cmeth);
   326 static inline void makeAccessDeletedObjectException(
ExceptionSink *xsink, 
const char *mem, 
const char *cname) {
   327     xsink->
raiseException(
"OBJECT-ALREADY-DELETED", 
"attempt to access member '%s' of an already-deleted object of class '%s'", mem, cname);
   330 static inline void makeAccessDeletedObjectException(
ExceptionSink *xsink, 
const char *cname) {
   331     xsink->
raiseException(
"OBJECT-ALREADY-DELETED", 
"attempt to access an already-deleted object of class '%s'", cname);
   341     DLLEXPORT QoreExternalProgramLocationWrapper(
const QoreExternalProgramLocationWrapper&);
   344     DLLEXPORT QoreExternalProgramLocationWrapper(QoreExternalProgramLocationWrapper&&);
   347     DLLEXPORT QoreExternalProgramLocationWrapper(
const char* file, 
int start_line, 
int end_line,
   348         const char* source = 
nullptr, 
int offset = 0, 
const char* lang = 
nullptr);
   351     DLLEXPORT ~QoreExternalProgramLocationWrapper();
   354     DLLEXPORT 
void set(
const char* file, 
int start_line, 
int end_line,
   355         const char* source = 
nullptr, 
int offset = 0, 
const char* lang = 
nullptr);
   358     DLLLOCAL 
const QoreProgramLocation& 
get() 
const {
   363     DLLLOCAL 
const std::string& getFile()
 const {
   368     DLLLOCAL 
const std::string& getSource()
 const {
   373     DLLLOCAL 
const std::string& getLanguage()
 const {
   378     DLLEXPORT 
int getStartLine() 
const;
   381     DLLEXPORT 
int getEndLine() 
const;
   385     std::string file_str;
   386     std::string source_str;
   387     std::string lang_str;
   390     QoreProgramLocation* loc;
   402     DLLLOCAL QoreStackLocation(
const QoreStackLocation&) = 
default;
   405     DLLLOCAL QoreStackLocation(QoreStackLocation&&) = 
default;
   408     DLLLOCAL 
virtual ~QoreStackLocation() = 
default;
   411     DLLLOCAL QoreStackLocation& operator=(
const QoreStackLocation&) = 
default;
   414     DLLLOCAL QoreStackLocation& operator=(QoreStackLocation&&) = 
default;
   424     DLLLOCAL 
void setNext(
const QoreStackLocation* next) {
   429     DLLLOCAL 
virtual const QoreStackLocation* getNext()
 const {
   437     DLLLOCAL 
virtual const AbstractStatement* getStatement() 
const = 0;
   440     DLLLOCAL 
virtual const std::string& getCallName() 
const = 0;
   443     DLLLOCAL 
virtual qore_call_t getCallType() 
const = 0;
   446     DLLLOCAL 
virtual const QoreProgramLocation& getLocation() 
const = 0;
   449     const QoreStackLocation* stack_next = 
nullptr;
   456     friend class qore_external_runtime_stack_location_helper_priv;
   462     DLLEXPORT QoreExternalStackLocation(
const QoreExternalStackLocation&);
   465     DLLEXPORT QoreExternalStackLocation(QoreExternalStackLocation&&);
   468     DLLEXPORT 
virtual ~QoreExternalStackLocation();
   471     DLLLOCAL QoreExternalStackLocation& operator=(
const QoreExternalStackLocation&) = 
delete;
   474     DLLLOCAL QoreExternalStackLocation& operator=(QoreExternalStackLocation&&) = 
delete;
   480     DLLEXPORT 
virtual const AbstractStatement* getStatement() 
const;
   483     class qore_external_stack_location_priv* priv;
   495     DLLEXPORT QoreExternalRuntimeStackLocationHelper(
const QoreExternalRuntimeStackLocationHelper&);
   498     DLLEXPORT QoreExternalRuntimeStackLocationHelper(QoreExternalRuntimeStackLocationHelper&&);
   501     DLLEXPORT ~QoreExternalRuntimeStackLocationHelper();
   504     DLLLOCAL QoreExternalRuntimeStackLocationHelper& operator=(
const QoreExternalRuntimeStackLocationHelper&) = 
delete;
   507     DLLLOCAL QoreExternalRuntimeStackLocationHelper& operator=(QoreExternalRuntimeStackLocationHelper&&) = 
delete;
   510     class qore_external_runtime_stack_location_helper_priv* priv;
 DLLEXPORT void handleWarnings()
calls ExceptionSink::defaultWarningHandler() on all exceptions still present in the object and then d...
 
DLLEXPORT void outOfMemory()
intended to be used to handle out of memory errors FIXME: not yet fully implemented ...
 
DLLEXPORT const QoreValue getExceptionArg()
returns the argument of the top exception 
 
DLLEXPORT ~ExceptionSink()
calls ExceptionSink::defaultExceptionHandler() on all exceptions still present in the object and then...
 
DLLEXPORT void handleExceptions()
calls ExceptionSink::defaultExceptionHandler() on all exceptions still present in the object and then...
 
returns a custom Qore program location for external modules to generate runtime exceptions with the s...
Definition: ExceptionSink.h:335
 
Stack location element abstract class. 
Definition: ExceptionSink.h:396
 
std::string lang
the source language 
Definition: ExceptionSink.h:276
 
DLLEXPORT AbstractQoreNode * raiseExceptionArg(const char *err, QoreValue arg, const char *fmt,...)
appends a Qore-language exception to the list, and sets the 'arg' member (this object takes over the ...
 
Stack location element abstract class for external binary modules. 
Definition: ExceptionSink.h:455
 
The base class for all value and parse types in Qore expression trees. 
Definition: AbstractQoreNode.h:54
 
std::string label
the code label name (source file if source not present) 
Definition: ExceptionSink.h:270
 
DLLEXPORT AbstractQoreNode * raiseException(const char *err, const char *fmt,...)
appends a Qore-language exception to the list 
 
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...
 
DLLEXPORT const QoreValue getExceptionErr()
returns the error of the top exception 
 
DLLEXPORT int appendLastDescription(const char *fmt,...)
appends a formatted string to the top exception description if the desc value is a string ...
 
Qore's string value type, reference counted, dynamically-allocated only. 
Definition: QoreStringNode.h:50
 
DLLEXPORT QoreProgram * getProgram()
returns the current QoreProgram 
 
This is the list container type in Qore, dynamically allocated only, reference counted. 
Definition: QoreListNode.h:52
 
std::string code
the function or method call name; method calls in format class::name 
Definition: ExceptionSink.h:275
 
The main value class in Qore, designed to be passed by value. 
Definition: QoreValue.h:262
 
supports parsing and executing Qore-language code, reference counted, dynamically-allocated only ...
Definition: QoreProgram.h:126
 
DLLEXPORT void clear()
deletes the exception list immediately 
 
int start_line
the start line 
Definition: ExceptionSink.h:271
 
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:46
 
Sets the stack location for external modules providing language support. 
Definition: ExceptionSink.h:489
 
qore_call_t type
the call stack element type 
Definition: ExceptionSink.h:292
 
DLLEXPORT bool isThreadExit() const
returns true if thread_exit has been triggered 
 
DLLEXPORT void raiseThreadExit()
sets the "thread_exit" flag; will cause the current thread to terminate 
 
DLLEXPORT const QoreValue getExceptionDesc()
returns the description of the top exception 
 
DLLEXPORT ExceptionSink()
creates an empty ExceptionSink object 
 
Qore source location; strings must be in the default encoding for the Qore process. 
Definition: ExceptionSink.h:269
 
std::string source
optional additional source file 
Definition: ExceptionSink.h:273
 
DLLEXPORT bool isException() const
returns true if at least one exception is present 
 
Qore call stack. 
Definition: ExceptionSink.h:310
 
DLLEXPORT void assimilate(ExceptionSink *xs)
assimilates all entries of the "xs" argument by appending them to the internal list and deletes the "...
 
DLLEXPORT bool isEvent() const
returns true if at least one exception is present or thread_exit has been triggered ...
 
call stack element; strings must be in the default encoding for the Qore process 
Definition: ExceptionSink.h:291