|
Qore Programming Language
0.9.16
|
32 #ifndef _QORE_EXCEPTIONSINK_H
34 #define _QORE_EXCEPTIONSINK_H
44 hashdecl QoreProgramLocation;
49 friend hashdecl qore_es_private;
54 hashdecl qore_es_private* priv;
91 DLLEXPORT
operator bool ()
const;
226 DLLEXPORT
void raiseException(
const QoreProgramLocation& loc,
const char* err,
QoreValue arg,
const char* fmt, ...);
241 DLLEXPORT
void clear();
261 DLLLOCAL QoreException* catchException();
262 DLLLOCAL QoreException* getException();
263 DLLLOCAL
void overrideLocation(
const QoreProgramLocation& loc);
264 DLLLOCAL
void rethrow(QoreException* old);
266 DLLLOCAL
static void defaultExceptionHandler(QoreException* e);
267 DLLLOCAL
static void defaultWarningHandler(QoreException* e);
269 DLLLOCAL
static void outputExceptionLocation(
const char* fns,
int start_line,
int end_line,
const char* srcs,
270 int offset,
const char* langs,
const char* types);
274 enum qore_call_t :
signed char {
299 const char*
code,
const char*
lang =
"Qore") :
311 const char*
lang =
"Qore") :
321 typedef std::vector<QoreCallStackElement> callstack_vec_t;
328 DLLEXPORT
void add(qore_call_t type,
const char* label,
int start,
int end,
const char* code,
329 const char* lang =
"Qore");
332 DLLEXPORT
void add(qore_call_t type,
const char* label,
int start,
int end,
const char* source,
333 unsigned offset,
const char* code,
const char* lang =
"Qore");
336 static inline void alreadyDeleted(
ExceptionSink *xsink,
const char *cmeth) {
337 xsink->
raiseException(
"OBJECT-ALREADY-DELETED",
"the method %s() cannot be executed because the object has already been deleted", cmeth);
340 static inline void makeAccessDeletedObjectException(
ExceptionSink *xsink,
const char *mem,
const char *cname) {
341 xsink->
raiseException(
"OBJECT-ALREADY-DELETED",
"attempt to access member '%s' of an already-deleted object of class '%s'", mem, cname);
344 static inline void makeAccessDeletedObjectException(
ExceptionSink *xsink,
const char *cname) {
345 xsink->
raiseException(
"OBJECT-ALREADY-DELETED",
"attempt to access an already-deleted object of class '%s'", cname);
362 const char* source =
nullptr,
int offset = 0,
const char* lang =
nullptr);
368 DLLEXPORT
void set(
const char* file,
int start_line,
int end_line,
369 const char* source =
nullptr,
int offset = 0,
const char* lang =
nullptr);
372 DLLLOCAL
const QoreProgramLocation&
get()
const {
399 std::string file_str;
400 std::string source_str;
401 std::string lang_str;
404 QoreProgramLocation* loc;
451 DLLLOCAL
virtual const AbstractStatement*
getStatement()
const = 0;
454 DLLLOCAL
virtual const std::string&
getCallName()
const = 0;
457 DLLLOCAL
virtual qore_call_t
getCallType()
const = 0;
460 DLLLOCAL
virtual const QoreProgramLocation&
getLocation()
const = 0;
470 friend class qore_external_runtime_stack_location_helper_priv;
494 DLLEXPORT
virtual const AbstractStatement*
getStatement()
const;
497 class qore_external_stack_location_priv* priv;
524 class qore_external_runtime_stack_location_helper_priv* priv;
DLLEXPORT void clear()
deletes the exception list immediately
DLLLOCAL void setNext(const QoreStackLocation *next)
called when pushed on the stack to set the next location
Definition: ExceptionSink.h:438
virtual DLLLOCAL QoreProgram * getProgram() const =0
returns the QoreProgram container
supports parsing and executing Qore-language code, reference counted, dynamically-allocated only
Definition: QoreProgram.h:126
The main value class in Qore, designed to be passed by value.
Definition: QoreValue.h:262
std::string code
the function or method call name; method calls in format class::name
Definition: ExceptionSink.h:291
const DLLLOCAL QoreProgramLocation & get() const
returns the source location
Definition: ExceptionSink.h:372
DLLEXPORT bool isEvent() const
returns true if at least one exception is present or thread_exit has been triggered
DLLEXPORT int getStartLine() const
returns the start line
virtual const DLLEXPORT AbstractStatement * getStatement() const
returns the statement for the call for internal Qore code
DLLEXPORT ~QoreExternalProgramLocationWrapper()
destructor; frees memory
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...
DLLLOCAL QoreExternalStackLocation & operator=(const QoreExternalStackLocation &)=delete
no assignment operator
DLLLOCAL QoreStackLocation & operator=(const QoreStackLocation &)=default
default assignment operator
DLLEXPORT void handleExceptions()
calls ExceptionSink::defaultExceptionHandler() on all exceptions still present in the object and then...
const DLLLOCAL std::string & getFile() const
returns the file name
Definition: ExceptionSink.h:377
std::string source
optional additional source file
Definition: ExceptionSink.h:289
class for C++ exception based on an ExceptionSink object
Definition: QoreXSinkException.h:51
DLLEXPORT ExceptionSink()
creates an empty ExceptionSink object
virtual const DLLLOCAL QoreProgramLocation & getLocation() const =0
returns the source location of the element
const DLLEXPORT QoreValue getExceptionDesc()
returns the description of the top exception
const DLLEXPORT QoreValue getExceptionArg()
returns the argument of the top exception
virtual const DLLLOCAL QoreStackLocation * getNext() const
returns the next location in the stack or nullptr if there is none
Definition: ExceptionSink.h:443
This is the list container type in Qore, dynamically allocated only, reference counted.
Definition: QoreListNode.h:52
returns a custom Qore program location for external modules to generate runtime exceptions with the s...
Definition: ExceptionSink.h:349
unsigned offset
offset in source file (only used if source is not empty)
Definition: ExceptionSink.h:290
DLLEXPORT int appendLastDescription(const char *fmt,...)
appends a formatted string to the top exception description if the desc value is a string
DLLEXPORT void raiseThreadExit()
sets the "thread_exit" flag; will cause the current thread to terminate
const DLLLOCAL std::string & getLanguage() const
returns the language
Definition: ExceptionSink.h:387
DLLEXPORT void outOfMemory()
intended to be used to handle out of memory errors FIXME: not yet fully implemented
virtual const DLLLOCAL AbstractStatement * getStatement() const =0
returns the statement for the call for internal Qore code
DLLEXPORT ~ExceptionSink()
calls ExceptionSink::defaultExceptionHandler() on all exceptions still present in the object and then...
DLLEXPORT AbstractQoreNode * raiseException(const char *err, const char *fmt,...)
appends a Qore-language exception to the list
Stack location element abstract class for external binary modules.
Definition: ExceptionSink.h:469
DLLEXPORT QoreExternalStackLocation()
create the object
DLLEXPORT int getEndLine() const
returns the start line
DLLEXPORT void assimilate(ExceptionSink *xs)
assimilates all entries of the "xs" argument by appending them to the internal list and deletes the "...
DLLLOCAL QoreExternalRuntimeStackLocationHelper & operator=(const QoreExternalRuntimeStackLocationHelper &)=delete
no assignment operator
virtual DLLLOCAL qore_call_t getCallType() const =0
returns the call type
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:48
DLLEXPORT void handleWarnings()
calls ExceptionSink::defaultWarningHandler() on all exceptions still present in the object and then d...
virtual DLLLOCAL ~QoreStackLocation()=default
virtual destructor
Qore source location; strings must be in the default encoding for the Qore process.
Definition: ExceptionSink.h:285
virtual DLLEXPORT QoreProgram * getProgram() const
returns the QoreProgram container
Qore call stack.
Definition: ExceptionSink.h:326
virtual DLLEXPORT ~QoreExternalStackLocation()
destroys the object
call stack element; strings must be in the default encoding for the Qore process
Definition: ExceptionSink.h:307
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 ...
DLLEXPORT bool isException() const
returns true if at least one exception is present
const DLLLOCAL std::string & getSource() const
returns the source
Definition: ExceptionSink.h:382
DLLEXPORT void add(qore_call_t type, const char *label, int start, int end, const char *code, const char *lang="Qore")
add an element to the end of the stack trace
std::string lang
the source language
Definition: ExceptionSink.h:292
DLLLOCAL QoreStackLocation()
constructor
const DLLEXPORT QoreValue getExceptionErr()
returns the error of the top exception
DLLEXPORT ~QoreExternalRuntimeStackLocationHelper()
Restores the old runtime location.
int start_line
the start line
Definition: ExceptionSink.h:287
DLLEXPORT bool isThreadExit() const
returns true if thread_exit has been triggered
Qore's string value type, reference counted, dynamically-allocated only.
Definition: QoreStringNode.h:50
Sets the stack location for external modules providing language support.
Definition: ExceptionSink.h:503
The base class for all value and parse types in Qore expression trees.
Definition: AbstractQoreNode.h:54
DLLEXPORT void set(const char *file, int start_line, int end_line, const char *source=nullptr, int offset=0, const char *lang=nullptr)
sets the program source location
DLLEXPORT QoreExternalProgramLocationWrapper()
empty constructor; use set() to set the location
qore_call_t type
the call stack element type
Definition: ExceptionSink.h:308
DLLEXPORT QoreExternalRuntimeStackLocationHelper()
Sets the current runtime location.
virtual const DLLLOCAL std::string & getCallName() const =0
returns the name of the function or method call
std::string label
the code label name (source file if source not present)
Definition: ExceptionSink.h:286
int end_line
the end line
Definition: ExceptionSink.h:288
Stack location element abstract class.
Definition: ExceptionSink.h:410