dxFeed Graal Native SDK 3.11.0
Loading...
Searching...
No Matches
Exceptions

The exception that a failed function of the C API leaves for the calling thread. More...

Data Structures

struct  dxfg_stack_trace_element_t
 An element of the stack trace of an exception: one frame, the same data as a Java StackTraceElement. More...
struct  dxfg_stack_trace_element_list
 The stack trace of an exception: a list of its frames, the innermost call first. More...
struct  dxfg_exception_t
 An exception that was thrown by the Java side: the class, the message, the stack trace and the cause. More...

Typedefs

typedef struct dxfg_stack_trace_element_t dxfg_stack_trace_element_t
 An element of the stack trace of an exception: one frame, the same data as a Java StackTraceElement.
typedef struct dxfg_stack_trace_element_list dxfg_stack_trace_element_list
 The stack trace of an exception: a list of its frames, the innermost call first.
typedef struct dxfg_exception_t dxfg_exception_t
 An exception that was thrown by the Java side: the class, the message, the stack trace and the cause.

Functions

dxfg_exception_t * dxfg_get_and_clear_thread_exception_t (graal_isolatethread_t *thread)
 Returns the exception of the last failed function call of the calling thread and clears it.
void dxfg_Exception_release (graal_isolatethread_t *thread, dxfg_exception_t *exception)
 Releases an exception that was returned by dxfg_get_and_clear_thread_exception_t().

Detailed Description

The exception that a failed function of the C API leaves for the calling thread.

A function of the C API that fails returns an error value (it is given in the @return of each function, see dxfg_common.h for DXFG_EXECUTE_FAIL) and stores the Java exception that caused the failure for the thread that called it. dxfg_get_and_clear_thread_exception_t() returns the stored exception as a dxfg_exception_t, and dxfg_Exception_release() releases it.

Typedef Documentation

◆ dxfg_exception_t

typedef struct dxfg_exception_t dxfg_exception_t

An exception that was thrown by the Java side: the class, the message, the stack trace and the cause.

It is returned by dxfg_get_and_clear_thread_exception_t() and owned by the caller: release it with dxfg_Exception_release(), which frees the structure, its strings, its stack trace and the whole chain of causes. Every pointer inside the structure belongs to it; copy what has to outlive the structure.

Javadoc

◆ dxfg_stack_trace_element_list

typedef struct dxfg_stack_trace_element_list dxfg_stack_trace_element_list

The stack trace of an exception: a list of its frames, the innermost call first.

The structure belongs to the dxfg_exception_t that contains it and is freed with it by dxfg_Exception_release().

◆ dxfg_stack_trace_element_t

typedef struct dxfg_stack_trace_element_t dxfg_stack_trace_element_t

An element of the stack trace of an exception: one frame, the same data as a Java StackTraceElement.

The structure and its strings belong to the dxfg_exception_t that contains it and are freed with it by dxfg_Exception_release(). A string that the Java side has no value for is NULL.

Javadoc

Function Documentation

◆ dxfg_Exception_release()

void dxfg_Exception_release ( graal_isolatethread_t * thread,
dxfg_exception_t * exception )

Releases an exception that was returned by dxfg_get_and_clear_thread_exception_t().

Frees the structure together with its strings, its stack trace and its whole chain of causes. A NULL pointer is ignored. Do not use the structure or the pointers inside it afterwards. The function does not report errors.

Java: not applicable (the structure is allocated by the SDK outside the Java heap).

Parameters
[in]threadThe current GraalVM Isolate's thread.
[in]exceptionThe exception to release.

◆ dxfg_get_and_clear_thread_exception_t()

dxfg_exception_t * dxfg_get_and_clear_thread_exception_t ( graal_isolatethread_t * thread)

Returns the exception of the last failed function call of the calling thread and clears it.

Call it when a function reported an error (see the @return of that function) to learn what went wrong. The exception is stored per thread: this function returns the exception of the thread that calls it (the thread parameter is not used to choose it), so call it on the thread on which the function failed. The stored exception is cleared by this call: a second call returns NULL until another function fails.

A function that completes successfully does not clear the stored exception, so call this function right after the error: otherwise it can return the exception of an earlier failure that was not taken. When several functions fail on a thread before the exception is taken, only the exception of the last failure is returned.

Java: JNIThreadLocalPendingException.get() and JNIThreadLocalPendingException.clear() (GraalVM native image), the result is converted from Throwable.

Parameters
[in]threadThe current GraalVM Isolate's thread.
Returns
The exception (release it with dxfg_Exception_release()), or NULL if no exception is stored for the calling thread.